How do I move a line or range of lines to a different location in the file?
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
161 results for "paste"
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
"0p vs "1p
Register 0 always contains the last yanked text.
yy
The yy command yanks (copies) the entire current line, including the newline character.
:put a ... edit ... "ayy
Recorded macros are stored as plain text in registers, but editing them by re-recording is tedious for complex sequences.
"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.
"1p then u.u.u.
Vim stores your last 9 deletions (of one line or more) in the numbered registers "1 through "9.
registers #registers #editing #normal-mode #undo-redo #paste
"1p through "9p
Registers 1-9 contain the last 9 deletions or changes that are at least one line long.
dd
The dd command deletes the entire current line, regardless of where the cursor is positioned on that line.
y/<C-r>"<CR>
To search for the exact text you have selected in visual mode, yank it and paste it into the search prompt.
".p
The ".
registers #registers #editing #insert-mode #normal-mode #productivity
let @a = 'macro_contents'
Recorded macros are stored in registers, which are lost when you quit Vim (unless viminfo saves them).
"%p
The % register in Vim always contains the name of the current file.
registers #registers #editing #insert-mode #productivity #filename
"ap, edit, "ayy
Vim stores macros in registers, which means you can paste a macro's contents into a buffer, edit it as regular text, and yank it back into the register.
:call setreg('a', @a, 'l')
Registers in Vim have a type — characterwise, linewise, or blockwise — that affects how their contents are pasted.
:windo diffthis
The :windo diffthis command activates Vim's built-in diff mode across all visible windows, highlighting the differences between them.
"ap, edit, 0"ay$
When a macro has a small mistake, re-recording the entire thing is tedious.
:<C-r>"
When typing an Ex command or search pattern, you often need to insert text you've already yanked or deleted.
"#p or <C-r># in insert mode
The # register always contains the name of the alternate file — typically the file you were editing just before the current one.
"/
Vim stores the last search pattern in the special / register.
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.