In normal mode (in Vim) if the cursor is on a number, hitting Ctrl-A increments the number by 1. Now I want to do the same thing, but from the command line. Specifically, I want to go to certain lines whose first character is a number, and increment it, i.e., I want to run the following command:
:g/searchString/ Ctrl-A
I tried to store Ctrl-A in a macro (say a
), and using :g/searchString/ @a
, but I get an error:
E492: Not an editor command ^A
Any suggestions?
Ctrl-w = tells Vim to assign an equal number of lines to each viewport.
If we are in the vim editor, then simply do this, “Press the ENTER key, write the Line number, and press Shift+ g”: Again the output is the same.
You have to use normal
to execute normal mode commands in command mode:
:g/searchString/ normal ^A
Note that you have to press Ctrl-VCtrl-A to get the ^A
character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With