Tutorial by Examples

One way to create a macro is to record it. Start recording a macro and save it to a register (in this example, we'll use a, but it can be any register you could normally yank text to): qa Then run the commands you want to record in the macro (here, we'll surround the contents of a line with &lt...
Sometimes you will make a mistake with a lengthy macro, but would rather edit it than re-record it entirely. You can do this using the following process: Put the macro on an empty line with "<register>p. If your macro is saved in register a, the command is "ap. Edit the ma...
Vim macros can also be recursive. This is useful for when you need to act on every line (or other text object) till the end of the file. To record a recursive macro, start with an empty register. (A register can be emptied using q<register>q.) Choose a consistent starting point on each line ...
A macro is a series of keystrokes meant to be "played back" by Vim without any delay. Macros can be stored in registers or variables, bound to keys, or executed on the command line. Here is a simple macro that uppercases the third word on a line: 0wwgUiw That macro could be recorded i...
with q command we could simplify a lot of tedious work in vim. example 1. generate array sequence (1 to 20). STEP 1. press i to enter insert mode, input 1 1 STEP 2. Record following action: "append the last number to the next line, and increment the number" type esc to exit input...

Page 1 of 1