Command reference
Everything : takes. Abbreviations are in the right-hand column; any of them work.
Files
| Command |
|
|
:w |
write |
:write |
:w PATH |
write there, and edit that from now on |
|
:q |
quit, refusing if there is unsaved work |
:quit |
:q! |
quit anyway |
:quit! |
:wq |
write and quit |
:x :xit |
:e PATH |
open a file |
:edit |
:e |
read this one off the disk again |
|
:e! |
…discarding what you changed |
:edit! |
:recover |
put the recovery copy into the buffer |
|
:recover! |
discard it |
|
ZZ is :wq without the colon.
Buffers
| Command |
|
|
:ls |
list the open buffers |
:buffers :files |
:bn |
the next one |
:bnext |
:bp |
the one before |
:bprev :bprevious :bN |
:b NAME |
the one whose name matches |
:bu :buffer |
Windows
| Command |
|
|
:sp [PATH] |
split horizontally |
:split :new |
:vsp [PATH] |
split vertically |
:vs :vsplit :vnew |
:clo |
close this window |
:close |
:on |
close every other one |
:only |
Searching and substituting
| Command |
|
|
:s/from/to/[flags] |
substitute (see searching) |
|
:noh |
stop highlighting matches |
:nohl :nohlsearch |
:marks |
list the marks |
|
Ranges: % the whole file, . this line, $ the last, 1,5 a span, .+1 relative.
Flags: g every match on the line, i ignore case, n count and change nothing.
Find in project
| Command |
|
|
:grep [PATTERN] |
open the find dialog, optionally pre-filled |
:gr |
:copen |
show the quickfix list in a window |
:cope :cw |
:cclose |
close that window; the list stays |
:ccl |
:cn |
the next entry |
:cnext |
:cp |
the one before |
:cprev :cprevious :cN |
:cc |
the current one again |
|
:cfirst |
the first entry |
:cfir |
:clast |
the last |
:cla |
:cdo s/from/to/g |
substitute on the line of every entry, and write |
|
:find |
the fuzzy file picker |
:fin |
Ctrl+G is :grep and Ctrl+P is :find.
Settings
| Command |
|
|
:set nu / :set nonu |
line numbers |
number nonumber |
:set rnu / :set nornu |
relative numbers |
relativenumber |
:set hls / :set nohls |
highlight search matches |
|
:set syntax |
say what this is coloured as |
:set syn |
:set syntax=NAME |
colour it as that |
:set syn=NAME |
:set nosyntax |
plain |
:set nosyn :set syntax=off |
:set ff |
say which line endings |
:set fileformat |
:set ff=unix / :set ff=dos |
write LF, write CRLF |
|
:set eol / :set noeol |
end the file with a newline, or not |
|
:set encoding=NAME |
write in that encoding |
|
Other
| Command |
|
:42 |
go to line 42 |
:help |
the one-line summary of the keys (:h) |
An unknown command says not an editor command: NAME.