`
When we yank or delete text it is stored in a register where we can put/paste it later by pressing P or p.
In insert mode we can put/paste text from the default register by pressing control+r and then "
We can yank into registers a - z
To yank in word to register a press "ayiw
To put from register a press "ap
To put from register a in insert mode press control+r a
To yank text into register b from visual mode, go into visual mode (with control+v) and select the text you would like to yank. Then press "by
To paste from register b in visual mode, go into visual mode (with control+v) select text and press the lower case c (for change) and paste from register b from insert mode with "bp
Append text in a register by yanking/deleting text into the upper case letter, replace text in a register by yanking/deleting into the lower case letter
You can see what is in the registers by typing :registers
There are some special registers:
/ is the path register
% current document register
: last command register
. repeat command register
0 last yanked register
" default register
- last deleted register
1-9 Last delete line register
Vim Macros allow you to record and play a sequence of actions inside of the Vim editor.
Macros are stored in the registers (a-z) - The same registers that we use to yank and delete text into.
Pressing "q" and a register letter will start recording the Macro into that register then press "q" again to stop recording the Macro .
To play the Macro, press "@" and the register where he Macro is stored.
In Vim, numbers can be incremented by 1 by pressing control+a on a line with a number (and you are on the number or to the left of the number.)
Decrementing numbers by 1 in Vim works the same way as incrementing, the only change is control+x is pressed instead of control+a on a line with a number (and you are on the number or to the left of the number.)
To increment the number by something other than 1, that number would be typed in before before pressing control+a. Decrementing by a number other than one works the same as incrementing only the number would be pressed before control-x is pressed.
Incrementing/decrementing numbers can be used in macros
In this video tutorial, we also copy a macro and see we need to press control+v to before we can add control+x to our copied macro.
We use Visual Block mode to update a group increment a block of numbers
We insert line numbers in the lines in the document, then we look at how to left justify right justify and zero fill to the left of the line number we added.