How to remap repeating commands i.e. ?How can I start vim and then execute a particular command that includes a , from the command line?Key mapping that will invoke the wildmenuSticky shift - or getting <shift> with letter combinationsHow to find out what a key is mapped to?How to remember the most basic commandsColon remap not working for registers(?)How to remap <C-W>hjkl to navigate tmux panes and vim splitsFactoring out commands in vimrc?Getting Shift-Tab to work in VIM Insert modeHow to get the number used before a command as an argument?

Was Mohammed the most popular first name for boys born in Berlin in 2018?

Whose birthyears are canonically established in the MCU?

When was it publicly revealed that a KH-11 spy satellite took pictures of the first Shuttle flight?

How can I test a shell script in a "safe environment" to avoid harm to my computer?

Opposite party turned away from voting when ballot is all opposing party

Why doesn't a particle exert force on itself?

Is the tensor product (of vector spaces) commutative?

Employee is self-centered and affects the team negatively

What will Doctor Strange protect now?

Two (probably) equal real numbers which are not proved to be equal?

Is your maximum jump distance halved by grappling?

As a small race with a heavy weapon, does enlage remove the disadvantage?

Capturing the entire webpage with WebExecute's CaptureImage

Cyclic queue using an array in C#

Exactly which act of bravery are Luke and Han awarded a medal for?

How can one see if an address is multisig?

Sed operations are not working or might i am doing it wrong?

How do I minimise waste on a flight?

Align a table column at a specific symbol

Is there an application which does HTTP PUT?

Why doesn't Dany protect her dragons better?

How can it be that ssh somename works, while nslookup somename does not?

Would the rotation of the starfield from a ring station be too disorienting?

Can I bring back Planetary Romance as a genre?



How to remap repeating commands i.e. ?


How can I start vim and then execute a particular command that includes a , from the command line?Key mapping that will invoke the wildmenuSticky shift - or getting <shift> with letter combinationsHow to find out what a key is mapped to?How to remember the most basic commandsColon remap not working for registers(?)How to remap <C-W>hjkl to navigate tmux panes and vim splitsFactoring out commands in vimrc?Getting Shift-Tab to work in VIM Insert modeHow to get the number used before a command as an argument?













2















By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing <S-g> does something different than just 5<S-g>. How can I remap a command that takes a number for repeated executions?



Something like: nnoremap <number>g <number>G










share|improve this question







New contributor



DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    2















    By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing <S-g> does something different than just 5<S-g>. How can I remap a command that takes a number for repeated executions?



    Something like: nnoremap <number>g <number>G










    share|improve this question







    New contributor



    DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      2












      2








      2








      By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing <S-g> does something different than just 5<S-g>. How can I remap a command that takes a number for repeated executions?



      Something like: nnoremap <number>g <number>G










      share|improve this question







      New contributor



      DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing <S-g> does something different than just 5<S-g>. How can I remap a command that takes a number for repeated executions?



      Something like: nnoremap <number>g <number>G







      key-bindings normal-mode






      share|improve this question







      New contributor



      DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked May 4 at 19:11









      DJTripleThreatDJTripleThreat

      1134




      1134




      New contributor



      DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      DJTripleThreat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          5














          nnoremap g G


          But this will not work well, as there are a lot of key mapping beginning with g. So Vim has to wait a timeout (default 1000 msec) to be sure that no other key is pressed after the g. The g could be the start of 'gg' or 'g$' or ...



          So after you pressed 5g nothing will happen for one second. Than the cursor jumps to line 5.



          If you want to know about the other key mappings starting with 'g' just enter ':help g' and then hit <tab>. Lots of stuff.






          share|improve this answer























          • Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

            – DJTripleThreat
            May 4 at 23:14


















          2














          Even though OP accepted the existing answer this feels incomplete to me.



          First, the answer has a well-considered warning about remapping g but there
          is no mention of <count>gg as a near-synonym for <count>G. (They differ only when the count is omitted. By default gg goes to the first line and G to the last.). Perhaps entering 5gg is less annoying to OP than 5 Shift+G and we have a nice, easy workaround...



          The other thing that feels unaddressed is the subject of the question which is notably more generic than what has actually been discussed. It happens to be a good question, about applying a repeat count to a mapped command, but folks who come here from google will have to keep looking if it's not answered. So...



          From Normal mode, if one precedes a command with a count and that command enters a vimscript/ex context we can retrieve the count from that context with the built-in variable v:count.



          I'll use it in an example applicable to the more specific question we've been addressing...



          nnoremap XX :<C-U>exe 'norm! ' . v:count . 'G'<CR>


          In place of XX choose any key or keys you like better than Shift+G and this will
          give you a replacement for <count>G.



          FYI about the use of <C-U> (see :h c_CTRL-U): this is required to clear the command line before the mapped command is applied. Normally when we enter a number followed by : the command line is pre-populated with a line range. In this case we don't want that.






          share|improve this answer




















          • 1





            Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

            – dedowsdi
            2 days ago











          • @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

            – B Layer
            2 days ago












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "599"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          );



          );






          DJTripleThreat is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f19841%2fhow-to-remap-repeating-commands-i-e-numbercommand%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5














          nnoremap g G


          But this will not work well, as there are a lot of key mapping beginning with g. So Vim has to wait a timeout (default 1000 msec) to be sure that no other key is pressed after the g. The g could be the start of 'gg' or 'g$' or ...



          So after you pressed 5g nothing will happen for one second. Than the cursor jumps to line 5.



          If you want to know about the other key mappings starting with 'g' just enter ':help g' and then hit <tab>. Lots of stuff.






          share|improve this answer























          • Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

            – DJTripleThreat
            May 4 at 23:14















          5














          nnoremap g G


          But this will not work well, as there are a lot of key mapping beginning with g. So Vim has to wait a timeout (default 1000 msec) to be sure that no other key is pressed after the g. The g could be the start of 'gg' or 'g$' or ...



          So after you pressed 5g nothing will happen for one second. Than the cursor jumps to line 5.



          If you want to know about the other key mappings starting with 'g' just enter ':help g' and then hit <tab>. Lots of stuff.






          share|improve this answer























          • Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

            – DJTripleThreat
            May 4 at 23:14













          5












          5








          5







          nnoremap g G


          But this will not work well, as there are a lot of key mapping beginning with g. So Vim has to wait a timeout (default 1000 msec) to be sure that no other key is pressed after the g. The g could be the start of 'gg' or 'g$' or ...



          So after you pressed 5g nothing will happen for one second. Than the cursor jumps to line 5.



          If you want to know about the other key mappings starting with 'g' just enter ':help g' and then hit <tab>. Lots of stuff.






          share|improve this answer













          nnoremap g G


          But this will not work well, as there are a lot of key mapping beginning with g. So Vim has to wait a timeout (default 1000 msec) to be sure that no other key is pressed after the g. The g could be the start of 'gg' or 'g$' or ...



          So after you pressed 5g nothing will happen for one second. Than the cursor jumps to line 5.



          If you want to know about the other key mappings starting with 'g' just enter ':help g' and then hit <tab>. Lots of stuff.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 4 at 19:57









          RalfRalf

          3,9651319




          3,9651319












          • Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

            – DJTripleThreat
            May 4 at 23:14

















          • Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

            – DJTripleThreat
            May 4 at 23:14
















          Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

          – DJTripleThreat
          May 4 at 23:14





          Thanks for this. I realized soon after remapping g was a bad idea haha! Ill check out the help text for that command.

          – DJTripleThreat
          May 4 at 23:14











          2














          Even though OP accepted the existing answer this feels incomplete to me.



          First, the answer has a well-considered warning about remapping g but there
          is no mention of <count>gg as a near-synonym for <count>G. (They differ only when the count is omitted. By default gg goes to the first line and G to the last.). Perhaps entering 5gg is less annoying to OP than 5 Shift+G and we have a nice, easy workaround...



          The other thing that feels unaddressed is the subject of the question which is notably more generic than what has actually been discussed. It happens to be a good question, about applying a repeat count to a mapped command, but folks who come here from google will have to keep looking if it's not answered. So...



          From Normal mode, if one precedes a command with a count and that command enters a vimscript/ex context we can retrieve the count from that context with the built-in variable v:count.



          I'll use it in an example applicable to the more specific question we've been addressing...



          nnoremap XX :<C-U>exe 'norm! ' . v:count . 'G'<CR>


          In place of XX choose any key or keys you like better than Shift+G and this will
          give you a replacement for <count>G.



          FYI about the use of <C-U> (see :h c_CTRL-U): this is required to clear the command line before the mapped command is applied. Normally when we enter a number followed by : the command line is pre-populated with a line range. In this case we don't want that.






          share|improve this answer




















          • 1





            Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

            – dedowsdi
            2 days ago











          • @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

            – B Layer
            2 days ago
















          2














          Even though OP accepted the existing answer this feels incomplete to me.



          First, the answer has a well-considered warning about remapping g but there
          is no mention of <count>gg as a near-synonym for <count>G. (They differ only when the count is omitted. By default gg goes to the first line and G to the last.). Perhaps entering 5gg is less annoying to OP than 5 Shift+G and we have a nice, easy workaround...



          The other thing that feels unaddressed is the subject of the question which is notably more generic than what has actually been discussed. It happens to be a good question, about applying a repeat count to a mapped command, but folks who come here from google will have to keep looking if it's not answered. So...



          From Normal mode, if one precedes a command with a count and that command enters a vimscript/ex context we can retrieve the count from that context with the built-in variable v:count.



          I'll use it in an example applicable to the more specific question we've been addressing...



          nnoremap XX :<C-U>exe 'norm! ' . v:count . 'G'<CR>


          In place of XX choose any key or keys you like better than Shift+G and this will
          give you a replacement for <count>G.



          FYI about the use of <C-U> (see :h c_CTRL-U): this is required to clear the command line before the mapped command is applied. Normally when we enter a number followed by : the command line is pre-populated with a line range. In this case we don't want that.






          share|improve this answer




















          • 1





            Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

            – dedowsdi
            2 days ago











          • @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

            – B Layer
            2 days ago














          2












          2








          2







          Even though OP accepted the existing answer this feels incomplete to me.



          First, the answer has a well-considered warning about remapping g but there
          is no mention of <count>gg as a near-synonym for <count>G. (They differ only when the count is omitted. By default gg goes to the first line and G to the last.). Perhaps entering 5gg is less annoying to OP than 5 Shift+G and we have a nice, easy workaround...



          The other thing that feels unaddressed is the subject of the question which is notably more generic than what has actually been discussed. It happens to be a good question, about applying a repeat count to a mapped command, but folks who come here from google will have to keep looking if it's not answered. So...



          From Normal mode, if one precedes a command with a count and that command enters a vimscript/ex context we can retrieve the count from that context with the built-in variable v:count.



          I'll use it in an example applicable to the more specific question we've been addressing...



          nnoremap XX :<C-U>exe 'norm! ' . v:count . 'G'<CR>


          In place of XX choose any key or keys you like better than Shift+G and this will
          give you a replacement for <count>G.



          FYI about the use of <C-U> (see :h c_CTRL-U): this is required to clear the command line before the mapped command is applied. Normally when we enter a number followed by : the command line is pre-populated with a line range. In this case we don't want that.






          share|improve this answer















          Even though OP accepted the existing answer this feels incomplete to me.



          First, the answer has a well-considered warning about remapping g but there
          is no mention of <count>gg as a near-synonym for <count>G. (They differ only when the count is omitted. By default gg goes to the first line and G to the last.). Perhaps entering 5gg is less annoying to OP than 5 Shift+G and we have a nice, easy workaround...



          The other thing that feels unaddressed is the subject of the question which is notably more generic than what has actually been discussed. It happens to be a good question, about applying a repeat count to a mapped command, but folks who come here from google will have to keep looking if it's not answered. So...



          From Normal mode, if one precedes a command with a count and that command enters a vimscript/ex context we can retrieve the count from that context with the built-in variable v:count.



          I'll use it in an example applicable to the more specific question we've been addressing...



          nnoremap XX :<C-U>exe 'norm! ' . v:count . 'G'<CR>


          In place of XX choose any key or keys you like better than Shift+G and this will
          give you a replacement for <count>G.



          FYI about the use of <C-U> (see :h c_CTRL-U): this is required to clear the command line before the mapped command is applied. Normally when we enter a number followed by : the command line is pre-populated with a line range. In this case we don't want that.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          B LayerB Layer

          6,1221620




          6,1221620







          • 1





            Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

            – dedowsdi
            2 days ago











          • @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

            – B Layer
            2 days ago













          • 1





            Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

            – dedowsdi
            2 days ago











          • @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

            – B Layer
            2 days ago








          1




          1





          Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

          – dedowsdi
          2 days ago





          Nice to know <count>gg. You might need to explain <c-u>, some user might consider it as a mistake, they don't know :h N: . You command also need a trailing <cr>.

          – dedowsdi
          2 days ago













          @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

          – B Layer
          2 days ago






          @dedowsdi Thanks for the heads up about the <cr> that I left off. And you're right about explaining <c-u>...I was being lazy and planned to fill it out later. :)

          – B Layer
          2 days ago











          DJTripleThreat is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          DJTripleThreat is a new contributor. Be nice, and check out our Code of Conduct.












          DJTripleThreat is a new contributor. Be nice, and check out our Code of Conduct.











          DJTripleThreat is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Vi and Vim Stack Exchange!


          • 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%2fvi.stackexchange.com%2fquestions%2f19841%2fhow-to-remap-repeating-commands-i-e-numbercommand%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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form