Visual Block Mode edit with sequential number [duplicate]How to write incremental lines in Vim?Vertically rotate visual blockIs there a command to enter Visual Block mode?Can I select and edit specific positions in lines while in visual block mode?extra newlines when pasting altered string in visual block modePassing visual range to a :command as its argumentVim ^V Visual Block mode not workingWould you ever want to start recording a macro from the quickfix window?combining two map commandsBind visual mode 'I' and 'A' to always use visual block mode before insertingJump to bottom of block in Visual Block mode

Why are C64 games inconsistent with which joystick port they use?

How do I know what is the origin IP if I ping from a router to a host of an external network in packet tracer?

Who will lead the country until there is a new Tory leader?

Why do Windows registry hives appear empty?

Boss wants me to falsify a report. How should I document this unethical demand?

How to respond to an upset student?

I think I may have violated academic integrity last year - what should I do?

NIntegrate doesn't evaluate

Wireless Multipoint Bridging / Backhaul Gateway Antenna and AP Selection

Does the unit of measure matter when you are solving for the diameter of a circumference?

How strong are Wi-Fi signals?

Looking for a soft substance that doesn't dissolve underwater

How to know if a folder is a symbolic link?

the meaning of 'carry' in a novel

Would jet fuel for an F-16 or F-35 be producible during WW2?

Defining the standard model of PA so that a space alien could understand

Why does a perfectly-identical repetition of a drawing command given within an earlier loop 𝘯𝘰𝘵 produce exactly the same line?

Simple fuzz pedal using breadboard

What is the object moving across the ceiling in this stock footage?

Why do most published works in medical imaging try to reduce false positives?

My employer faked my resume to acquire projects

Why colon to denote that a value belongs to a type?

Is the Starlink array really visible from Earth?

Why did David Cameron offer a referendum on the European Union?



Visual Block Mode edit with sequential number [duplicate]


How to write incremental lines in Vim?Vertically rotate visual blockIs there a command to enter Visual Block mode?Can I select and edit specific positions in lines while in visual block mode?extra newlines when pasting altered string in visual block modePassing visual range to a :command as its argumentVim ^V Visual Block mode not workingWould you ever want to start recording a macro from the quickfix window?combining two map commandsBind visual mode 'I' and 'A' to always use visual block mode before insertingJump to bottom of block in Visual Block mode













5
















This question already has an answer here:



  • How to write incremental lines in Vim?

    4 answers



Suppose I'd like to create a list



- "1"
- "2"
- "3"


what Is the smartest way to create such?



My attempt would be to i- "1"ESCyypp to get



- "1"
- "1"
- "1"


and then jump to the second line's 1 r2jr3



BUT: doing this for a list of e.g. 100 (also thinking about the second digit) is not what I want to do with technique above...



I am using nvim v0.3.5 von archLinux, but i don't think, that that does matter.










share|improve this question







New contributor



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










marked as duplicate by Hotschke, Rich, statox May 21 at 9:19


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















    5
















    This question already has an answer here:



    • How to write incremental lines in Vim?

      4 answers



    Suppose I'd like to create a list



    - "1"
    - "2"
    - "3"


    what Is the smartest way to create such?



    My attempt would be to i- "1"ESCyypp to get



    - "1"
    - "1"
    - "1"


    and then jump to the second line's 1 r2jr3



    BUT: doing this for a list of e.g. 100 (also thinking about the second digit) is not what I want to do with technique above...



    I am using nvim v0.3.5 von archLinux, but i don't think, that that does matter.










    share|improve this question







    New contributor



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










    marked as duplicate by Hotschke, Rich, statox May 21 at 9:19


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















      5












      5








      5









      This question already has an answer here:



      • How to write incremental lines in Vim?

        4 answers



      Suppose I'd like to create a list



      - "1"
      - "2"
      - "3"


      what Is the smartest way to create such?



      My attempt would be to i- "1"ESCyypp to get



      - "1"
      - "1"
      - "1"


      and then jump to the second line's 1 r2jr3



      BUT: doing this for a list of e.g. 100 (also thinking about the second digit) is not what I want to do with technique above...



      I am using nvim v0.3.5 von archLinux, but i don't think, that that does matter.










      share|improve this question







      New contributor



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












      This question already has an answer here:



      • How to write incremental lines in Vim?

        4 answers



      Suppose I'd like to create a list



      - "1"
      - "2"
      - "3"


      what Is the smartest way to create such?



      My attempt would be to i- "1"ESCyypp to get



      - "1"
      - "1"
      - "1"


      and then jump to the second line's 1 r2jr3



      BUT: doing this for a list of e.g. 100 (also thinking about the second digit) is not what I want to do with technique above...



      I am using nvim v0.3.5 von archLinux, but i don't think, that that does matter.





      This question already has an answer here:



      • How to write incremental lines in Vim?

        4 answers







      visual-mode macro visual-block line-numbers






      share|improve this question







      New contributor



      Joel 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



      Joel 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



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








      asked May 20 at 15:02









      JoelJoel

      1283




      1283




      New contributor



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




      New contributor




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






      marked as duplicate by Hotschke, Rich, statox May 21 at 9:19


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Hotschke, Rich, statox May 21 at 9:19


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          3 Answers
          3






          active

          oldest

          votes


















          8














          Depending on your usecase the following might be useful:



          Create the entries all with the number "1":



          - "1"
          - "1"
          - "1"
          - "1"


          Then go to the second "1" and press V to start line-wise visual. Then move down to the last "1". So now all but the first "1" is selected.



          Now hit gCtrl-a and you get



          - "1"
          - "2"
          - "3"
          - "4"


          See :help v_g_CTRL-A



          Update: What if a I need a new number "3" and all following should be increased by one?



          First insert the new line:



          - "1"
          - "2"
          - "3"
          - "3"
          - "4"


          Then go to the second "3", hit V and move down to the end of the list. Now hit Ctrl-a (without leading g) and the selected numbers are increased by one.



          You get:



          - "1"
          - "2"
          - "3"
          - "4"
          - "5"





          share|improve this answer




















          • 2





            and additional +1 for the :help v_g_CTRL-A

            – Joel
            May 20 at 15:34






          • 2





            I had no clue of v_g_CTRL-A, brilliant! you have my vote.

            – padawin
            May 20 at 15:45











          • Note that v_g_CTRL-A is only available since vim 8.1.

            – TonioElGringo
            May 21 at 10:51


















          2














          Here's a shorter macro version.



          First write a single line with the contents



          - "1"


          Then type the following:



          qqyypCtrl-Aq98@q




          • qq—start recording


          • yyp—Duplicate the line


          • Ctrl-A—Increment the number


          • q—End the recording


          • 98@q—Replay 98 times





          share|improve this answer
































            1














            I would do it as follow:



            • Somewhere in your file (before where you want your list), add a line with the first number - 1 (most likely 0),

            • Make a mark at this place (ma)

            • Make an empty line where you want your list and make another mark there (mb)

            Your file would, at this point, look like this (The lines 1 and 2 don't matter, they are just here to say where the marks are):



            enter image description here



            • Record the following macro:

             qq // Start the macro in register q
            `a // go to mark a
            CTRL-a // Increase the number
            yiw // Copy the number
            `b // Go to mark b
            i- " // Go in insert mode, insert - "
            <esc>p // leave the insert mode and paste the number
            A"<CR><esc> // Closes the quote, add a new line and leave the insert mode
            mb // Update the mark b to be here
            q // Stop recording the macro

            100@q // Run the macro 100 times


            You can delete the line where the mark a is, as it was just to store the counter.



            And voila.






            share|improve this answer

























            • I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

              – Joel
              May 20 at 15:17






            • 1





              I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

              – padawin
              May 20 at 15:19


















            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            8














            Depending on your usecase the following might be useful:



            Create the entries all with the number "1":



            - "1"
            - "1"
            - "1"
            - "1"


            Then go to the second "1" and press V to start line-wise visual. Then move down to the last "1". So now all but the first "1" is selected.



            Now hit gCtrl-a and you get



            - "1"
            - "2"
            - "3"
            - "4"


            See :help v_g_CTRL-A



            Update: What if a I need a new number "3" and all following should be increased by one?



            First insert the new line:



            - "1"
            - "2"
            - "3"
            - "3"
            - "4"


            Then go to the second "3", hit V and move down to the end of the list. Now hit Ctrl-a (without leading g) and the selected numbers are increased by one.



            You get:



            - "1"
            - "2"
            - "3"
            - "4"
            - "5"





            share|improve this answer




















            • 2





              and additional +1 for the :help v_g_CTRL-A

              – Joel
              May 20 at 15:34






            • 2





              I had no clue of v_g_CTRL-A, brilliant! you have my vote.

              – padawin
              May 20 at 15:45











            • Note that v_g_CTRL-A is only available since vim 8.1.

              – TonioElGringo
              May 21 at 10:51















            8














            Depending on your usecase the following might be useful:



            Create the entries all with the number "1":



            - "1"
            - "1"
            - "1"
            - "1"


            Then go to the second "1" and press V to start line-wise visual. Then move down to the last "1". So now all but the first "1" is selected.



            Now hit gCtrl-a and you get



            - "1"
            - "2"
            - "3"
            - "4"


            See :help v_g_CTRL-A



            Update: What if a I need a new number "3" and all following should be increased by one?



            First insert the new line:



            - "1"
            - "2"
            - "3"
            - "3"
            - "4"


            Then go to the second "3", hit V and move down to the end of the list. Now hit Ctrl-a (without leading g) and the selected numbers are increased by one.



            You get:



            - "1"
            - "2"
            - "3"
            - "4"
            - "5"





            share|improve this answer




















            • 2





              and additional +1 for the :help v_g_CTRL-A

              – Joel
              May 20 at 15:34






            • 2





              I had no clue of v_g_CTRL-A, brilliant! you have my vote.

              – padawin
              May 20 at 15:45











            • Note that v_g_CTRL-A is only available since vim 8.1.

              – TonioElGringo
              May 21 at 10:51













            8












            8








            8







            Depending on your usecase the following might be useful:



            Create the entries all with the number "1":



            - "1"
            - "1"
            - "1"
            - "1"


            Then go to the second "1" and press V to start line-wise visual. Then move down to the last "1". So now all but the first "1" is selected.



            Now hit gCtrl-a and you get



            - "1"
            - "2"
            - "3"
            - "4"


            See :help v_g_CTRL-A



            Update: What if a I need a new number "3" and all following should be increased by one?



            First insert the new line:



            - "1"
            - "2"
            - "3"
            - "3"
            - "4"


            Then go to the second "3", hit V and move down to the end of the list. Now hit Ctrl-a (without leading g) and the selected numbers are increased by one.



            You get:



            - "1"
            - "2"
            - "3"
            - "4"
            - "5"





            share|improve this answer















            Depending on your usecase the following might be useful:



            Create the entries all with the number "1":



            - "1"
            - "1"
            - "1"
            - "1"


            Then go to the second "1" and press V to start line-wise visual. Then move down to the last "1". So now all but the first "1" is selected.



            Now hit gCtrl-a and you get



            - "1"
            - "2"
            - "3"
            - "4"


            See :help v_g_CTRL-A



            Update: What if a I need a new number "3" and all following should be increased by one?



            First insert the new line:



            - "1"
            - "2"
            - "3"
            - "3"
            - "4"


            Then go to the second "3", hit V and move down to the end of the list. Now hit Ctrl-a (without leading g) and the selected numbers are increased by one.



            You get:



            - "1"
            - "2"
            - "3"
            - "4"
            - "5"






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 20 at 15:50

























            answered May 20 at 15:27









            RalfRalf

            4,1551319




            4,1551319







            • 2





              and additional +1 for the :help v_g_CTRL-A

              – Joel
              May 20 at 15:34






            • 2





              I had no clue of v_g_CTRL-A, brilliant! you have my vote.

              – padawin
              May 20 at 15:45











            • Note that v_g_CTRL-A is only available since vim 8.1.

              – TonioElGringo
              May 21 at 10:51












            • 2





              and additional +1 for the :help v_g_CTRL-A

              – Joel
              May 20 at 15:34






            • 2





              I had no clue of v_g_CTRL-A, brilliant! you have my vote.

              – padawin
              May 20 at 15:45











            • Note that v_g_CTRL-A is only available since vim 8.1.

              – TonioElGringo
              May 21 at 10:51







            2




            2





            and additional +1 for the :help v_g_CTRL-A

            – Joel
            May 20 at 15:34





            and additional +1 for the :help v_g_CTRL-A

            – Joel
            May 20 at 15:34




            2




            2





            I had no clue of v_g_CTRL-A, brilliant! you have my vote.

            – padawin
            May 20 at 15:45





            I had no clue of v_g_CTRL-A, brilliant! you have my vote.

            – padawin
            May 20 at 15:45













            Note that v_g_CTRL-A is only available since vim 8.1.

            – TonioElGringo
            May 21 at 10:51





            Note that v_g_CTRL-A is only available since vim 8.1.

            – TonioElGringo
            May 21 at 10:51











            2














            Here's a shorter macro version.



            First write a single line with the contents



            - "1"


            Then type the following:



            qqyypCtrl-Aq98@q




            • qq—start recording


            • yyp—Duplicate the line


            • Ctrl-A—Increment the number


            • q—End the recording


            • 98@q—Replay 98 times





            share|improve this answer





























              2














              Here's a shorter macro version.



              First write a single line with the contents



              - "1"


              Then type the following:



              qqyypCtrl-Aq98@q




              • qq—start recording


              • yyp—Duplicate the line


              • Ctrl-A—Increment the number


              • q—End the recording


              • 98@q—Replay 98 times





              share|improve this answer



























                2












                2








                2







                Here's a shorter macro version.



                First write a single line with the contents



                - "1"


                Then type the following:



                qqyypCtrl-Aq98@q




                • qq—start recording


                • yyp—Duplicate the line


                • Ctrl-A—Increment the number


                • q—End the recording


                • 98@q—Replay 98 times





                share|improve this answer















                Here's a shorter macro version.



                First write a single line with the contents



                - "1"


                Then type the following:



                qqyypCtrl-Aq98@q




                • qq—start recording


                • yyp—Duplicate the line


                • Ctrl-A—Increment the number


                • q—End the recording


                • 98@q—Replay 98 times






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 20 at 17:10

























                answered May 20 at 16:10









                RichRich

                15.7k12168




                15.7k12168





















                    1














                    I would do it as follow:



                    • Somewhere in your file (before where you want your list), add a line with the first number - 1 (most likely 0),

                    • Make a mark at this place (ma)

                    • Make an empty line where you want your list and make another mark there (mb)

                    Your file would, at this point, look like this (The lines 1 and 2 don't matter, they are just here to say where the marks are):



                    enter image description here



                    • Record the following macro:

                     qq // Start the macro in register q
                    `a // go to mark a
                    CTRL-a // Increase the number
                    yiw // Copy the number
                    `b // Go to mark b
                    i- " // Go in insert mode, insert - "
                    <esc>p // leave the insert mode and paste the number
                    A"<CR><esc> // Closes the quote, add a new line and leave the insert mode
                    mb // Update the mark b to be here
                    q // Stop recording the macro

                    100@q // Run the macro 100 times


                    You can delete the line where the mark a is, as it was just to store the counter.



                    And voila.






                    share|improve this answer

























                    • I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

                      – Joel
                      May 20 at 15:17






                    • 1





                      I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

                      – padawin
                      May 20 at 15:19
















                    1














                    I would do it as follow:



                    • Somewhere in your file (before where you want your list), add a line with the first number - 1 (most likely 0),

                    • Make a mark at this place (ma)

                    • Make an empty line where you want your list and make another mark there (mb)

                    Your file would, at this point, look like this (The lines 1 and 2 don't matter, they are just here to say where the marks are):



                    enter image description here



                    • Record the following macro:

                     qq // Start the macro in register q
                    `a // go to mark a
                    CTRL-a // Increase the number
                    yiw // Copy the number
                    `b // Go to mark b
                    i- " // Go in insert mode, insert - "
                    <esc>p // leave the insert mode and paste the number
                    A"<CR><esc> // Closes the quote, add a new line and leave the insert mode
                    mb // Update the mark b to be here
                    q // Stop recording the macro

                    100@q // Run the macro 100 times


                    You can delete the line where the mark a is, as it was just to store the counter.



                    And voila.






                    share|improve this answer

























                    • I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

                      – Joel
                      May 20 at 15:17






                    • 1





                      I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

                      – padawin
                      May 20 at 15:19














                    1












                    1








                    1







                    I would do it as follow:



                    • Somewhere in your file (before where you want your list), add a line with the first number - 1 (most likely 0),

                    • Make a mark at this place (ma)

                    • Make an empty line where you want your list and make another mark there (mb)

                    Your file would, at this point, look like this (The lines 1 and 2 don't matter, they are just here to say where the marks are):



                    enter image description here



                    • Record the following macro:

                     qq // Start the macro in register q
                    `a // go to mark a
                    CTRL-a // Increase the number
                    yiw // Copy the number
                    `b // Go to mark b
                    i- " // Go in insert mode, insert - "
                    <esc>p // leave the insert mode and paste the number
                    A"<CR><esc> // Closes the quote, add a new line and leave the insert mode
                    mb // Update the mark b to be here
                    q // Stop recording the macro

                    100@q // Run the macro 100 times


                    You can delete the line where the mark a is, as it was just to store the counter.



                    And voila.






                    share|improve this answer















                    I would do it as follow:



                    • Somewhere in your file (before where you want your list), add a line with the first number - 1 (most likely 0),

                    • Make a mark at this place (ma)

                    • Make an empty line where you want your list and make another mark there (mb)

                    Your file would, at this point, look like this (The lines 1 and 2 don't matter, they are just here to say where the marks are):



                    enter image description here



                    • Record the following macro:

                     qq // Start the macro in register q
                    `a // go to mark a
                    CTRL-a // Increase the number
                    yiw // Copy the number
                    `b // Go to mark b
                    i- " // Go in insert mode, insert - "
                    <esc>p // leave the insert mode and paste the number
                    A"<CR><esc> // Closes the quote, add a new line and leave the insert mode
                    mb // Update the mark b to be here
                    q // Stop recording the macro

                    100@q // Run the macro 100 times


                    You can delete the line where the mark a is, as it was just to store the counter.



                    And voila.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 20 at 15:18

























                    answered May 20 at 15:13









                    padawinpadawin

                    7687




                    7687












                    • I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

                      – Joel
                      May 20 at 15:17






                    • 1





                      I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

                      – padawin
                      May 20 at 15:19


















                    • I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

                      – Joel
                      May 20 at 15:17






                    • 1





                      I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

                      – padawin
                      May 20 at 15:19

















                    I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

                    – Joel
                    May 20 at 15:17





                    I like the idea of using a variable. Is there an option to save (and increase) this variable inside a register? That would make the macro much shorter.

                    – Joel
                    May 20 at 15:17




                    1




                    1





                    I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

                    – padawin
                    May 20 at 15:19






                    I am not sure it is easily possible (without using a : command, which is fine too, but I don't think that would make the macro simpler). Maybe someone will have a suggestion to improve it?

                    – padawin
                    May 20 at 15:19




                    Popular posts from this blog

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

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?