How do I reindent a block of code using a visual selection?
= (in visual mode)
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
414 results for "G"
= (in visual mode)
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
cgn
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
<C-r><C-w>
When typing a command on the Vim command line, pressing inserts the word currently under the cursor.
<C-w>N
When using Vim's built-in :terminal, the buffer is in Terminal-Job mode by default, meaning all keystrokes go to the running shell.
:m +1
The :move command (abbreviated :m) relocates lines to a new position in the buffer without touching any registers.
$
The $ command moves the cursor to the last character of the current line.
p (in visual mode)
In visual mode, pressing p replaces the selected text with the contents of the default register.
/pattern1/;/pattern2/
Vim's search offsets allow chaining two patterns together with a semicolon.
<C-v>I#<Esc>
Vim's Visual Block mode lets you prepend characters (like comment markers) to multiple lines simultaneously.
:e %:r.html
In Vim's command line, % expands to the current buffer's filename.
command-line #ex-commands #command-line #buffers #navigation
w
The w command moves the cursor forward to the beginning of the next word.
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
'0
Pressing '0 in normal mode jumps to the exact cursor position in the most recently edited file, even after closing and reopening Vim.
!{motion}command
The ! operator in normal mode pipes text through an external shell command and replaces it with the output.
:set statusline=%f\ %y\ [%l/%L]
Vim's statusline option lets you build a custom status bar from format items.
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
iabbrev
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
<C-w>gf
gf reads the filename under the cursor and opens it in a new tab page, keeping your current buffer untouched.
:{range}!command
The :{range}!command syntax pipes the specified lines through an external shell command and replaces them with the output.
command-line #command-line #shell #filtering #unix #ex-commands
:<C-r>a
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r