Skip to content

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, round to the first after the last :bnext
:bp the one before, round to the last before the first :bprev :bprevious :bN
:n the next one, stopping at the last :next
:N the one before, stopping at the first :prev :previous
:bfirst the first one :bf :brewind :br :first :fir :rewind :rew
:blast the last one :bl :last :la
: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 are % for the whole file, . for this line, $ for the last, 1,5 for a span and .+1 for one relative to the cursor. Flags: g every match on the line, i ignore case, I match 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.

Shell

Command
:%!CMD run the whole file through CMD and put back what it prints
:2,5!CMD the same for those lines; any range works
:!CMD run CMD; one line of output is the message, more opens a window
:w !CMD the same, with the buffer on its input: :w !wc -w

The command runs through the shell, so :%!sort | uniq works. One u takes a filter back. A command that fails leaves the text alone and shows the first line of its error. The output is captured: a command that needs the terminal, an editor or a pager, does not get one.

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 ic / :set noic ignore case when searching ignorecase
:set scs / :set noscs …unless the pattern has a capital in it smartcase
: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 commentstring=// %s how gc comments this buffer; %s is the text :set cms
:set reader / :set noreader show a Markdown file rendered, or its source
:set readerwidth=N the widest the rendering gets, 80 unless set; 0 for the window's width
:render NAME CMD render syntax NAME with CMD; {width} is the window's width
:render NAME / :render forget that renderer, list them all
: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
:reader show a Markdown file rendered, or its source again (gR)
:help the one-line summary of the keys (:h)

An unknown command says not an editor command: NAME.