VIM Code Editor

This is a simple example of a keyboard shortcuts and commands.

Modes

Esc

Enter Normal Mode

i

Enter Insert Mode

v

Enter Visual Mode

:

Enter Command Mode

File Management

:e filename

Open a file

:w

Save file

:wq or ZZ

Save and exit

:q!

Exit without saving

:saveas filename

Save file as

:bd

Close file

Navigation

h

Move left

j

Move down

k

Move up

l

Move right

0

Jump to beginning of line

$

Jump to end of line

w

Move forward one word

b

Move backward one word

gg

Move to start of file

G

Move to end of file

:number

Go to line number

Line Numbering

:set number

Show line numbers

:set relativenumber

Show relative line numbers

:set nonumber

Hide line numbers

Editing

x

Delete character

dd

Delete current line

yy

Copy (yank) line

p

Paste after cursor

P

Paste before cursor

u

Undo last change

Ctrl + r

Redo last undone change

r

Replace character

R

Replace multiple characters

cw

Change word

cc

Change entire line

Search & Replace

/pattern

Search forward

?pattern

Search backward

n

Repeat last search forward

N

Repeat last search backward

:%s/old/new/g

Replace all occurrences in file

:%s/old/new/gc

Replace with confirmation

Multiple Files & Tabs

:tabnew filename

Open a new tab

gt

Switch to next tab

gT

Switch to previous tab

:tabclose

Close current tab

:ls

Show open buffers

:b buffer_number

Switch to buffer

Window Splitting

:split filename

Horizontal split with filename

:vsplit filename

Vertical split with filename

Ctrl + w, w

Switch between splits