How do you paste from a specific register while in insert mode?
<C-r>a
In insert mode, press followed by the register name.
<C-r>a
In insert mode, press followed by the register name.
<C-r>=expand('%:t')<CR>
In insert mode, = opens the expression register.
"adiw then move, "aP and diw
Delete the first word into register a with "adiw, move to the second word, paste register a before with "aP, then delete the remaining original.
<C-r>=42*7<CR>
In insert mode, press = to access the expression register, type a math expression like 42*7, and press Enter to insert the result (294).
:let @a = toupper(@a)
Use Vimscript functions toupper() or tolower() with :let @a = toupper(@a) to convert the case of the entire register contents.
<C-r>#
The # register holds the alternate (previously edited) filename.
"_dd
Use the black hole register " before a delete command.
qaciWmyFunc(<C-r>")<Esc>q
Record a macro that changes the inner word, types the function name with opening paren, pastes the original word from the register, and closes the paren.
qaq:g/pattern/normal "Ayy
Clear register a with qaq, then use :g/pattern/normal "Ayy to append all matching lines to register a.
qaddpq
Record a macro that deletes the current line with dd and pastes it below the next line with p.
qagUlwq
Record a macro that uppercases the first letter of the current word with gUl, then moves to the next word with w.
qa/true\|false\ncgn<C-r>=@"=='true'?'false':'true'\n<Esc>q
Record a macro using cgn with an expression register to toggle between true and false.
:let @a='...' in vimrc
Add let @a='macro-keystrokes' to your vimrc file to have the macro available in every Vim session.
qavip:sort\n}jq
Record a macro that visually selects the inner paragraph, sorts its lines, then moves to the next paragraph.
qa80|i\n<Esc>jq
Record a macro that moves to column 80 using 80 , inserts a newline, and moves to the next line.
qayy:+1\nif getline('.')==@0|d|else|+1|endif\nq
Record a macro that yanks the current line and compares it with the next.
qa:s/\s\+$//e\n jq
Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down.
qa$bywdw0Pa <Esc>q
Record a macro that yanks the last word, deletes it, pastes it at the beginning of the line.
qaI<C-r>a<Esc>jq
Record a macro that inserts the contents of register a at the start of each line using a in insert mode, then moves down.
qaf,i"<Esc>la"<Esc>q
Record a macro that finds the next comma, inserts a quote before it, moves past the comma, and inserts a quote after.