Key reference¶
Every binding, by mode. :help inside the editor prints a one-line version of this. Where a key does something other than vim's, differences from vim says so.
Normal mode¶
Motions¶
| Key | |
|---|---|
h j k l |
left, down, up, right; j k by screen line through a wrapped line |
| ← ↓ ↑ → | the same |
w b e |
word forwards, back, to the end of one |
ge |
back to the end of the word before |
W B E gE |
the same, punctuation counted as part of the word |
0 |
the first column |
^ |
the first non-blank |
$ |
the end of the line |
+ Enter-ish - |
first non-blank of the next line, of the previous |
| Space | forward one character |
_ |
the first non-blank of this line |
gg G |
the first line, the last |
{ } |
back and forward a paragraph |
fc Fc |
to the next c on this line, or the previous |
tc Tc |
to just before it, either way |
; , |
the last f F t T again, the same way or the other |
H M L |
the top, middle and bottom line of the window; 3H the third from the top |
% |
to the bracket matching the next one on this line |
`a 'a |
to mark a: the character, or the line's first non-blank |
Paging and scrolling¶
| Key | |
|---|---|
| Ctrl+F Ctrl+B | forward, back a screenful |
| PgDn PgUp | the same |
| Ctrl+D Ctrl+U | half a screenful |
| Ctrl+E Ctrl+Y | move the view and leave the cursor where it is |
zt zz zb |
scroll so this line is at the top, the middle, the bottom |
Operators¶
| Key | |
|---|---|
d c y |
delete, change, yank |
> < |
indent, outdent |
! |
filter through a command: opens : on the lines, for the command to be typed |
gu gU g~ |
lowercase, uppercase, swap case |
gc |
comment out, or back in (see below) |
dd cc yy >> << !! |
the same, on the whole line |
guu gUU g~~ gcc |
the same, on the line; gugu and the like work too |
gc toggles the block as one: if every line with text on it is already a comment, it uncomments them all, otherwise it comments them all. The marker goes at the indent the lines share, and blank lines are left alone. The marker depends on the file's syntax; :set commentstring=// %s sets it for one that has none.
Each takes a count on either side and a motion or text object after: d2w, 2dw, ci", y}.
Text objects¶
| Key | |
|---|---|
iw aw iW aW |
a word, inner or around |
i( a( i) a) ib ab |
parentheses |
i{ a{ i} a} iB aB |
braces |
i[ a[ i] a] |
brackets |
i< a< i> a> |
angle brackets |
ip ap |
a paragraph; ap takes the blank lines after it |
it at |
inside an HTML or XML tag, or the tag and all; across lines |
i" a" i' a' |
i` a` |
Single-key edits¶
| Key | |
|---|---|
x X |
delete the character under the cursor, or before it |
D C |
delete, change to the end of the line |
s S |
substitute the character, the line |
rc |
replace the character with c |
~ |
swap its case |
J |
join the next line on |
gJ |
the same, without adding or removing spaces |
| Ctrl+A Ctrl+X | add one to the number under or after the cursor, take one away; 5Ctrl+A adds five. Decimal and 0x hex; 007 goes to 008, and hex stops at zero |
Y |
yank the whole line (vi's Y is yy) |
p P |
put after the cursor, before it |
o O |
open a line below, above |
Entering insert mode¶
| Key | |
|---|---|
i I |
before the cursor, before the first non-blank |
a A |
after the cursor, at the end of the line |
o O |
on a new line below, above |
R |
typing over the text; Backspace puts back what was there |
Undo, repeat, macros, marks¶
| Key | |
|---|---|
u |
undo |
| Ctrl+R | redo |
. |
repeat the last change |
qa … q |
record keystrokes into register a |
@a |
play them; 3@a three times |
@@ |
play the last one again |
ma |
put mark a here |
`a 'a |
go to it |
`` |
back to where the last jump started |
Registers¶
| Key | |
|---|---|
"x |
send the next command's text to register x |
"+y "+p |
the system clipboard; "* is the same |
Visual mode¶
| Key | |
|---|---|
v |
select characters |
V |
select lines |
| Ctrl+V | select a block, a rectangle of columns |
gv |
select again what was selected last |
o |
to the other end of the selection; O on a block, the other corner of the line |
iw ip i( … |
select a text object |
rc |
turn every selected character into c |
J gJ |
join the selected lines |
D X Y |
delete, yank the whole lines |
C S R |
change the whole lines |
I A |
insert at the start, after the end of the selection |
"x |
name the register for what comes next: "+y copies the selection to the clipboard |
| Esc | stop |
Any motion extends the selection; any operator applies to it, gc included. p puts a register in place of the selection. What it replaced goes to the unnamed register, so p again swaps them back. u makes the selection lowercase and U uppercase, as in vim.
On a block, d x y c s work on the rectangle, and p puts a yanked block back as a column. I and A insert before or after it: type on the top line, and Esc copies the text down every line of the block. A pads a line too short to reach; I leaves it alone.
Files, windows and search¶
| Key | |
|---|---|
/ ? |
search forwards, backwards |
n N |
the next match, the previous |
* # |
the word under the cursor, as a whole word, forwards and backwards |
| Ctrl+P | the fuzzy file picker |
| Ctrl+G | find in project |
Ctrl+W then w |
the next window |
Ctrl+W then h j k l |
the window left, down, up, right |
Ctrl+W then s v |
split horizontally, vertically |
Ctrl+W then c q |
close this window |
Ctrl+W then o |
close every other one |
ZZ |
write and quit |
gR |
show a Markdown file rendered, read-only; gR again, or i a I A o O to insert, for the source |
| Enter in the rendered view | follow the link under the cursor |
| Ctrl+O | back to where the last link was followed from |
: |
the command line |
| Ctrl+C | says type :q to exit; it does not quit |
The mouse belongs to your terminal¶
What you get¶
TurboVI does not turn on mouse reporting, so the pointer does what it does everywhere else: double-click a word, triple-click a line, drag to select, Cmd+C to copy, and paste it into another application.
A program can have the clicks or leave them to the terminal, never both. Mouse reporting is a mode of the terminal: switching it on hands this editor click coordinates and takes selecting and copying away from the terminal, because the terminal no longer sees the clicks. Placing the cursor with a click is worth less than being able to copy a line out, so the mouse stays where it was.
Copying a line without its number¶
Line numbers are off by default, which is what makes every drag clean. With :set nu
on, a terminal selects rectangles of the screen and the gutter is part of the screen,
so an ordinary drag takes the line numbers with the text. Hold Option while
you drag (iTerm2 and Terminal.app both read that as a rectangular selection) and
you can start it at the first column of the text and leave the numbers behind.
Scrolling¶
The wheel scrolls the way your terminal scrolls an alternate-screen program, which in iTerm2 and Terminal.app means it sends ↑ and ↓ and moves the cursor. Ctrl+E and Ctrl+Y move the view without the cursor, and Ctrl+F and Ctrl+B go by the screenful.
Pasting from outside¶
Cmd+V, Ctrl+Shift+V, a middle click or whatever else your terminal pastes with inserts the text, in any mode. It arrives as one paste, which makes a big one instant: a key press per character would take seconds.
Because it arrives as a paste, the characters are text: pasting dd in normal mode
types dd. One u takes the whole paste back.
"+p is the other way in. A macro can use it.
Insert mode¶
| Key | |
|---|---|
| Esc | back to normal mode |
| Enter | split the line; the new one starts at the same indent |
| Backspace | delete backwards |
| Ctrl+W | delete the word before the cursor |
| Ctrl+U | delete back to the indent; again, the indent too |
| Ctrl+R x | put register x as if typed; for the clipboard, use the terminal's paste |
| Tab | insert what the file indents with (see settings) |
| ← ↓ ↑ → | move without leaving insert mode |
Everything else you press is text.
The command line¶
| Key | |
|---|---|
| Enter | run it |
| Esc | abandon it |
| Backspace | delete backwards; on an empty line, abandon |
The find dialog¶
| Key | |
|---|---|
| ↑ ↓ | move through the hits |
| PgUp PgDn | a windowful at a time |
| Enter | open the hit, fill the quickfix list |
| Esc | close |
| Ctrl+A | ignore case |
| Ctrl+W | whole words |
| Ctrl+R | regular expression, on by default |
The quickfix pane¶
| Key | |
|---|---|
| Enter | go to the entry under the cursor |
Everything else is an ordinary buffer, so the motions all work.