Vim/tmux commands cheat sheet

Vim

An extremely non-exhaustive cheat sheet of helpful commands

Modes

i: insert mode

v: visual (highlight) mode

esc: normal mode

Getting around

hjkl: left/down/up/right

A: insert at end of line

$: jump to end of line

0: jump to beginning of line

gg: jump to beginning of file

G: jump to end of file

ctrl+d: scroll down

ctrl+u: scroll up

Inserting

I: insert at beginning of line

A: insert at end of line

o: insert on a newline after the current line

O: insert on a newline before the current line

Selecting (highlighting)

V: select whole line

viw: highlight word

vi{: highlight everything inside of {}

vi”: highlight everything inside of “, etc

Window

vv: vertical split

ss: horizontal split

Undo/redo

u: undo

ctrl+r: redo

Copy/paste

y: yank/copy

p: paste

x: cut

yy: copy current line

dd: cut current line

paste from computer clipboard: “* to select the right registry, p to paste

Indentation

>: indent selection

<: outdent selection

>>/<<: indent/outdent current line

=: auto-fix indentation of selection

Commenting

gcc: comment current line

gc: comment highlighted text

Other

/: find inside file

r: replace character with next typed character

:edit: reload file (if a change was made externally)

,”: surround current word with “”

,{: surround current word with {}

.: repeat last command

,ci: remove something inside of a contained space

c: when in visual mode, deletes and puts you in insert mode

%: toggle between opening/closing {}, “”, etc

:s/foo/bar/g: replace foo with bar in highlighted text

Nerdtree (file tree)

ctrl+backslash: open tree / jump to file in tree

r: refresh directory

R: refresh root

m: open menu (to create new files, delete, move, etc)

Tmux

prefix all commands with ctrl+b (or whatever you’ve mapped your tmux prefix as, mine is ctrl+a)

c: new session

,: rename session

s: split tab horizontally

v: split tab vertically

x: kill pane/window

n: jump to next session

H/J/K/L: resize pane in different directions

{ and }: switch panes

[: enter scroll mode

q: quit scroll mode

z: toggle making pane fullscreen