How do I make the = operator format code with an external tool like gofmt or black?
:set equalprg=gofmt
By default, Vim's = operator re-indents text using its internal rules.
config #config #editing #ex-commands #formatting #indentation
795 results for "G"
:set equalprg=gofmt
By default, Vim's = operator re-indents text using its internal rules.
config #config #editing #ex-commands #formatting #indentation
\U, \L, \u, \l, \e in :substitute replacement
Vim's substitute command supports in-replacement case conversion metacharacters that transform the case of matched text without extra scripting.
gUU
The gUU command uppercases every character on the current line instantly — no visual selection or motion required.
*
The command searches forward for the exact word under the cursor, jumping to the next occurrence.
:tselect
When a tag has multiple definitions (e.
Create plugin/myplugin.vim
A basic Vim plugin is just a .
:~
The :~ command repeats the last substitution but uses the current search pattern instead of the original pattern.
qa I1. <Esc>j q
This simple macro inserts a list number prefix at the beginning of each line.
:changes
How it works Vim maintains a change list that records the position of every change you make to a buffer.
gh (in netrw)
When browsing files with Vim's built-in netrw file explorer (:Explore or :Ex), hidden files starting with a dot (.
:/start/,/end/ {command}
Vim's range addressing lets you specify a line range using search patterns instead of explicit line numbers.
g0
When wrap is on, a long buffer line can span multiple screen (display) lines.
navigation #navigation #motions #wrap #display-lines #normal-mode
:%!tac
Vim doesn't have a built-in reverse command, but you can pipe the buffer through tac (reverse of cat) to flip line order.
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.
:v/pattern/command
:v (short for :vglobal) is the inverse of :g.
ggVG
While Vim doesn't have a built-in "entire buffer" text object, the ggVG sequence achieves it: go to the first line, enter line-wise visual mode, then select to
:s/pattern/\=expression/
The \= prefix in the replacement field of :s/// tells Vim to evaluate the right-hand side as a Vim script expression and use the result as the replacement text.
"/p
Vim stores the last search pattern in the search register "/.
s/pattern/\r/
In Vim substitutions, \r in the replacement string inserts a line break, creating a new line.
:/start/,/end/d
Instead of specifying line numbers for Ex command ranges, you can use search patterns.
command-line #ex-commands #editing #search #ranges #command-line