How do I use a macro to generate a numbered sequence in Vim?
qa Yp <C-a> q
By combining a macro with (increment number), you can quickly generate numbered sequences.
qa Yp <C-a> q
By combining a macro with (increment number), you can quickly generate numbered sequences.
/pattern1/;/pattern2/
Vim's search offsets allow chaining two patterns together with a semicolon.
<C-i>
Every time you make a "jump" — using G, /, %, :tag, , or similar commands — Vim records your position in the jump list.
:normal! {keys}
:normal {keys} executes keystrokes as if typed in Normal mode — but it respects your custom mappings and abbreviations.
When recording a macro, you can execute another macro inside it by pressing @b (or any register) during the recording.
g_
g moves the cursor to the last non-blank character of the current line — skipping trailing spaces and tabs.
guu / gUU
Vim's case operators gu (lowercase) and gU (uppercase) follow the same doubling convention as dd and yy: repeating the operator letter applies it to the whole c
<C-a> / <C-x> (vim-speeddating)
vim-speeddating (by Tim Pope) extends Vim's built-in and increment/decrement operators to understand dates, times, roman numerals, and other ordered sequences.
/\Cpattern
Vim's ignorecase and smartcase settings change how all searches behave globally.
:t.
The :t (short for :copy) command copies lines from one location to another.
zl and zh
When a line is longer than the window width and wrap is off, Vim can display only part of it.
r<CR>
You can split a line at the cursor without entering Insert mode by using r.
gM
The gM command moves the cursor to the horizontal middle of the current line, regardless of how long the line is.
:%normal @q
To apply a macro to every line in the file, use :%normal @q.
//
In Vim, pressing // (two forward slashes) in Normal mode repeats the last search pattern.
cr
The vim-abolish plugin (by tpope) provides a cr (coerce) operator that converts the word under the cursor between naming conventions with a single keystroke pai
:'<,'>norm @q
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
<C-v>I#<Esc>
Vim's Visual Block mode lets you prepend characters (like comment markers) to multiple lines simultaneously.
100@a
When you give a large count to a macro — such as 100@a — Vim automatically stops replaying the macro as soon as any step inside it fails.
U
In visual mode, pressing U converts all selected characters to uppercase and u converts them to lowercase.