Cheat sheet
The keys and commands you use every day come first, and the back has the rest of what a regular user looks up. Keys and Commands list everything. Inside the editor, :help prints a one-line summary. The PDF prints on both sides of one sheet.
Modes
|
|
i a |
insert before, after the cursor |
I A |
at the start, the end of the line |
o O |
on a new line below, above |
R |
type over the text |
| Ctrl+W Ctrl+R x |
while typing: delete a word, put a register |
| Ctrl+A Ctrl+X |
add to, take from a number |
v V Ctrl+V |
select characters, lines, a block |
gv |
the last selection again |
: |
the command line |
| Esc |
back to normal mode |
Moving
|
|
h j k l |
left, down, up, right |
w b e |
next word, previous, end of word |
0 ^ $ |
line start, first non-blank, end |
gg G :42 |
first line, last, line 42 |
{ } |
previous, next paragraph |
fc tc |
to c on this line, to just before it |
; , |
the last f t again, the other way |
% |
the matching bracket |
| Ctrl+F Ctrl+B |
a screen forward, back |
| Ctrl+D Ctrl+U |
half a screen |
Editing
|
|
x |
delete the character |
dd yy cc |
delete, yank, change the line |
dmotion |
delete to there: dw d$ d} |
cmotion |
change to there: cw ci" |
p P |
put after, before |
rc |
replace the character with c |
J |
join the next line on |
>> << |
indent, outdent |
~ |
swap case |
gcc gcmotion |
comment out, or back in |
u Ctrl+R |
undo, redo |
. |
repeat the last change |
A count goes in front: 3dd, 2w, 5j.
Text objects
|
|
iw aw |
a word, with its space |
i" a" |
inside quotes, with them |
i( i{ i[ |
inside brackets |
ip it |
a paragraph, inside a tag |
After an operator or in visual mode: ciw, da(, yi{.
Search
|
|
/text ?text |
search forward, backward |
n N |
next, previous match |
* # |
the word under the cursor, forward, back |
:%s/a/b/g |
replace every a with b |
:noh |
clear the highlight |
| Ctrl+G |
find in project |
:cn :cp |
next, previous hit |
:copen |
the list of hits |
Files
|
|
:w |
write |
:q :q! |
quit, quit discarding changes |
:wq ZZ |
write and quit |
:e path |
open a file |
| Ctrl+P |
fuzzy file picker |
:ls |
open buffers |
:bn :bp |
next, previous buffer |
gR |
read Markdown rendered, and back |
| Enter Ctrl+O |
follow a link when reading, go back |
Windows
|
|
:sp :vsp |
split across, side by side |
Ctrl+W w |
the next window |
Ctrl+W h j k l |
the window that way |
Ctrl+W c |
close this one |
Ctrl+W o |
close the others |
Registers, macros, marks
|
|
"a |
use register a for the next yank or put |
"+y "+p |
the system clipboard |
qa … q |
record a macro into a |
@a @@ |
play it, play the last again |
ma |
set mark a |
`a 'a |
to the mark, to its line |
Settings
|
|
:set nu :set rnu |
line numbers, relative |
:set hls |
highlight matches |
:set syntax=name |
colour as name |
:set cms=// %s |
how gc comments |
Put them in ~/.config/turbovi/config, one per line, to have them every time.
The back
More moving
|
|
W B E |
by word, punctuation included |
Fc Tc |
f t backwards |
ge gE |
back to the end of a word |
H M L |
top, middle, bottom of the window |
zt zz zb |
scroll this line to the top, middle, bottom |
`` |
back to where the last jump started |
+ - |
first non-blank, next line, previous |
| Ctrl+E Ctrl+Y |
scroll, leaving the cursor |
More editing
|
|
X |
delete the character before |
D C |
delete, change to the end of the line |
s S |
change the character, the line |
Y |
yank the line |
gU gu g~ |
upper, lower, swap case: gUiw |
@@ |
play the last macro again |
!! !motion |
filter lines through a command |
:%!cmd |
filter the whole file: :%!sort |
:!cmd |
run a command, see its output |
:w !cmd |
give it the buffer |
Visual block
|
|
| Ctrl+V |
select a rectangle |
d y c |
act on the rectangle |
I A |
type before, after it, on every line |
p |
put a yanked block back as a column |
Substitute
|
|
:s/a/b/ |
this line, first match |
% . $ |
whole file, this line, last line |
1,5 .+1 |
a span, a line relative to here |
g |
every match on the line |
i |
ignore case |
n |
count, change nothing |
Ranges go before s, flags after: :1,5s/a/b/gi.
Buffers, windows, project
|
|
:b name |
the buffer whose name matches |
:clo :on |
close this window, the others |
:find |
the file picker, as a command |
:grep text |
find in project, pre-filled |
:cfirst :clast |
first, last hit |
:cdo s/a/b/g |
substitute on every hit, and write |
:cclose |
close the list of hits |
The find dialog
|
|
| ↑ ↓ |
move through the hits |
| Enter |
open the hit, fill the list |
| Ctrl+A |
ignore case |
| Ctrl+W |
whole words |
| Ctrl+R |
regular expression |
| Esc |
close |
In the list of hits, Enter goes to one.
Files and recovery
|
|
:w path |
write there, and edit that |
:e |
read the file again |
:e! |
read it again, losing changes |
:recover |
bring back the crash copy |
:recover! |
throw it away |
:set ff=unix dos |
write LF, CRLF |
:set noeol |
no newline at the end |
:set encoding=name |
write in that encoding |
Starting
|
|
turbovi file |
where the cursor was last time |
turbovi file +42 |
on line 42 |
turbovi file +cmd |
run :cmd first |
turbovi a b |
two buffers |
Insert mode and the terminal
|
|
| Tab |
indent the way the file does |
| arrows |
move without leaving insert |
| a paste |
always text, one u undoes it |
| a double-click |
the terminal's own selection |
| Ctrl+C |
does not quit: :q does |