Why remapping key to causes Vim to behave weird?












0















nnoremap <End> <S-A>        " line comment


Pressing End key then produces the desired effect but vim also appends " line comment to the end of the line!



Is there any way to kinda let vim know where nnoremap directive ends?










share|improve this question



























    0















    nnoremap <End> <S-A>        " line comment


    Pressing End key then produces the desired effect but vim also appends " line comment to the end of the line!



    Is there any way to kinda let vim know where nnoremap directive ends?










    share|improve this question

























      0












      0








      0








      nnoremap <End> <S-A>        " line comment


      Pressing End key then produces the desired effect but vim also appends " line comment to the end of the line!



      Is there any way to kinda let vim know where nnoremap directive ends?










      share|improve this question














      nnoremap <End> <S-A>        " line comment


      Pressing End key then produces the desired effect but vim also appends " line comment to the end of the line!



      Is there any way to kinda let vim know where nnoremap directive ends?







      vim vimrc






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 8:36









      arkadytarkadyt

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          1














          This is a common pitfall. After :map, everything is taken as the right-hand side. I would recommend to place the comment on a separate line:



          " line comment
          nnoremap <End> <S-A>


          But if you really want to stick with the trailing comments, you can employ the default command separation (with |, with in a mapping has to be either escaped | or written as <Bar>) to append a separate comment "command":



          nnoremap <End> <S-A>|        " line comment




          PS: Instead of <S-A>, you can simply write A :help key-notation.






          share|improve this answer
























          • Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

            – arkadyt
            Jan 19 at 21:22













          • Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

            – Ingo Karkat
            Jan 20 at 18:06











          • I see! Thank you!

            – arkadyt
            Jan 20 at 19:27











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389481%2fwhy-remapping-end-key-to-s-a-causes-vim-to-behave-weird%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          This is a common pitfall. After :map, everything is taken as the right-hand side. I would recommend to place the comment on a separate line:



          " line comment
          nnoremap <End> <S-A>


          But if you really want to stick with the trailing comments, you can employ the default command separation (with |, with in a mapping has to be either escaped | or written as <Bar>) to append a separate comment "command":



          nnoremap <End> <S-A>|        " line comment




          PS: Instead of <S-A>, you can simply write A :help key-notation.






          share|improve this answer
























          • Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

            – arkadyt
            Jan 19 at 21:22













          • Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

            – Ingo Karkat
            Jan 20 at 18:06











          • I see! Thank you!

            – arkadyt
            Jan 20 at 19:27
















          1














          This is a common pitfall. After :map, everything is taken as the right-hand side. I would recommend to place the comment on a separate line:



          " line comment
          nnoremap <End> <S-A>


          But if you really want to stick with the trailing comments, you can employ the default command separation (with |, with in a mapping has to be either escaped | or written as <Bar>) to append a separate comment "command":



          nnoremap <End> <S-A>|        " line comment




          PS: Instead of <S-A>, you can simply write A :help key-notation.






          share|improve this answer
























          • Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

            – arkadyt
            Jan 19 at 21:22













          • Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

            – Ingo Karkat
            Jan 20 at 18:06











          • I see! Thank you!

            – arkadyt
            Jan 20 at 19:27














          1












          1








          1







          This is a common pitfall. After :map, everything is taken as the right-hand side. I would recommend to place the comment on a separate line:



          " line comment
          nnoremap <End> <S-A>


          But if you really want to stick with the trailing comments, you can employ the default command separation (with |, with in a mapping has to be either escaped | or written as <Bar>) to append a separate comment "command":



          nnoremap <End> <S-A>|        " line comment




          PS: Instead of <S-A>, you can simply write A :help key-notation.






          share|improve this answer













          This is a common pitfall. After :map, everything is taken as the right-hand side. I would recommend to place the comment on a separate line:



          " line comment
          nnoremap <End> <S-A>


          But if you really want to stick with the trailing comments, you can employ the default command separation (with |, with in a mapping has to be either escaped | or written as <Bar>) to append a separate comment "command":



          nnoremap <End> <S-A>|        " line comment




          PS: Instead of <S-A>, you can simply write A :help key-notation.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 18 at 14:29









          Ingo KarkatIngo Karkat

          17.5k22343




          17.5k22343













          • Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

            – arkadyt
            Jan 19 at 21:22













          • Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

            – Ingo Karkat
            Jan 20 at 18:06











          • I see! Thank you!

            – arkadyt
            Jan 20 at 19:27



















          • Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

            – arkadyt
            Jan 19 at 21:22













          • Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

            – Ingo Karkat
            Jan 20 at 18:06











          • I see! Thank you!

            – arkadyt
            Jan 20 at 19:27

















          Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

          – arkadyt
          Jan 19 at 21:22







          Thanks, @IngoKarkat, using pipe symbol worked! Weird though, escaping the pipe symbol actually breaks the trick for me. Using <Bar> instead of pipe doesn't work either. I use nvim.

          – arkadyt
          Jan 19 at 21:22















          Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

          – Ingo Karkat
          Jan 20 at 18:06





          Yes, <Bar> or | is for when you want to include the remainder in the mapping, which here is not what you want, so you have to use | here. But it's more common the other way around, that's why I mentioned that as well.

          – Ingo Karkat
          Jan 20 at 18:06













          I see! Thank you!

          – arkadyt
          Jan 20 at 19:27





          I see! Thank you!

          – arkadyt
          Jan 20 at 19:27


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389481%2fwhy-remapping-end-key-to-s-a-causes-vim-to-behave-weird%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          Puebla de Zaragoza

          Musa