How do I swap two adjacent lines?
ddp
The ddp sequence swaps the current line with the line below it.
43 results for "dd"
ddp
The ddp sequence swaps the current line with the line below it.
:%normal command
The :normal command executes normal mode commands programmatically on a range of lines.
"1p through "9p
Registers 1-9 contain the last 9 deletions or changes that are at least one line long.
:Git log --oneline --graph
Tim Pope's vim-fugitive provides a complete Git interface inside Vim.
qa...@aq
A recursive macro calls itself at the end of its recording, causing it to repeat until a motion or search fails.
!{motion}{program}
The ! operator in normal mode lets you pipe a range of text through any external program and replace it with the output.
qaq
How it works To clear a macro register, you simply start recording into that register and immediately stop.
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
:g/pattern/normal A;
The :global command combined with :normal lets you execute arbitrary normal mode keystrokes on every line that matches a pattern.
command-line #global #normal-mode #editing #ex-commands #batch-editing
:'<,'>norm I//
After making a visual selection, :norm {commands} executes normal-mode keystrokes on every line in the range.
<C-h> / <C-w> / <C-u>
Vim provides three levels of deletion directly in insert mode, so you don't need to switch to normal mode for small corrections.
<C-o>zz
When you are typing in insert mode and the cursor drifts near the top or bottom of the screen, you normally have to press , then zz, then i or a to continue edi
:help registers
Vim has 10 types of registers, each serving a specific purpose.
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
qaq qa...@aq @a
A recursive macro calls itself at the end of its recording, causing it to repeat indefinitely until a command inside it fails (like a search hitting the end of
:let @a = "content"
When a recorded macro has a typo or needs a small tweak, you don't have to re-record it entirely.
@"
Vim macros are stored in registers — and you can execute any register as a macro with @{register}.
:argdo execute 'normal @q' | update
:argdo runs an Ex command on every file in Vim's argument list (the arglist).
oil.nvim: edit directory listing like a buffer
oil.
:Git
The vim-fugitive plugin by Tim Pope provides an interactive Git status window that lets you stage, unstage, diff, and commit files entirely from within Vim.