How do I insert the word under the cursor into the Vim command line?
<C-r><C-w>
When typing a command on the Vim command line, pressing inserts the word currently under the cursor.
<C-r><C-w>
When typing a command on the Vim command line, pressing inserts the word currently under the cursor.
:let @a = 'hello world'
Use :let @a = 'text' to set register a to any string.
"ayy"byy
Yank the line twice into different registers.
"ayiw
Use "a to specify register a, then yiw to yank the inner word.
"a:'a,'by
Set marks with ma and mb, then yank the range between them into register a using "a:'a,'by.
"ayip
Use "ayip to yank the inner paragraph into register a.
"ayis
Use "ayis to yank the inner sentence into register a.
<C-v>jjll"ay
Enter visual block mode with , select the block, then "ay to yank the block into register a.
gg"aVGy
Go to the first line with gg, then visually select from there to the last line with VG, and yank into register a.
"aVaBy
Position cursor in a function, use VaB to visually select the block including braces, then "ay to yank into register a.
qa"bpq
While recording macro a, paste from register b with "bp.
:%s/<C-r>a/replacement/g
In command-line mode, a inserts the contents of register a.
""p
The unnamed register "" is the default target for yank, delete, and change operations.
:let @/ = 'pattern'
Use :let @/ = 'pattern' to set the search register directly.
"*p
The register represents the primary selection (middle-click paste in X11).
:call setreg('a', 'text')
Use setreg() to set register contents from Vimscript.
"_dP or use "0p
When pasting over a selection, the replaced text overwrites the unnamed register.
:put a
The :put a command pastes register a on a new line below the cursor.
%. # :
Vim has read-only registers: % (current filename), # (alternate filename), .
qa...q
Press q followed by a lowercase letter (a-z) to start recording into that register.