How to use vim editor


CTRL + g display file name and location info

CTRL + q Exit from scroll lock (freeze)

CTRL + s Lock and unlock (scroll freeze)


u undo

U undo all changes on a line

CTRL + r redo


dw delete a word

dd delete a whole line

d$ delete a whole line after cursor

p paste (deleted text)

cw delete a word and insert

c$ change to the end of line and insert


/ search forward

? search backward

n search next occurrence

N search in opposite direction

% to locate matching pair eg. () {} []

:%s/old/new/gc search and replace old with new

Run command

:! to run commands

:w filename.txt write current to disk

:#,#w filename.txt write # through # to disk

:r filename.txt insert to existing file

Working with multiple files

:ls list of current buffers

:b old.txt buffer back to open file

:badd read.txt open file (add to buffer)

:e new.txt open new file


w word forward

W WORDS forward

b word backward

B WORDS backward

e or E end of word

Ctrl + H high top screen

Ctrl + M medium screen

Ctrl + L bottom of screen

gg top

G bottom

Switch window

Ctrl + W + s split horizontal

Ctrl + W + v split vertical

Ctrl + W + h j k l (move windows)

Insert smarter

I insert at the beginning of line

A insert at the end of line

o insert below the cursor

O insert above the cursor

C delete all text to the end of line (enters insert mode)

D delete all text to the end of line only

J join (removes spacing)


:help word-motions

Leave a Comment

Your email address will not be published. Required fields are marked *