Вы находитесь на странице: 1из 2

VI Editor Cheat Sheet

by Eric Grivilers (ericg) via cheatography.com/639/cs/270/

Quitting

Motion

:x

Exit, saving changes

Move left

Move to botton of screen

:q

Exit as long as there have been no


changes

Move down

Move to associated ( ), { }, [ ]

Move up

:0

ZZ

Exit and save changes if any have


been made

Move right

Move to the beginning of the


le

Move to next word

Move to the end of the le

Exit and ignore any changes

:$

:q!

Move to next blank delimited


word

[ctrl] +
d

go down half a screen

Move to the beginning of the


word

[ctrl] +
u

go up half a screen

Move to the beginning of blank


delimted word

[ctrl] +
f

go forward a screen

[ctrl] +
b

go back a screen

Inserting Text

Motion (cont)

Insert before cursor

Insert before line

Append after cursor

Append after line

Move to the end of the word

Open a new line after current line

Open a new line before current line

Move to the end of Blank


delimited word

Replace one character

Move a sentence back

Replace many characters

Move a sentence forward

Move a paragraph back

Move a paragraph forward

Move to the begining of the line

Move to the end of the line

1G

Move to the rst line of the le

Move to the last line of the le

nG

Move to nth line of the le

:n

Move to nth line of the le

fc

Move forward to c

Fc

Move back to c

Deleting Text

Move to top of screen

Move to middle of screen

Delete character to the right of


cursor

Delete character to the left of


cursor

Delete to the end of the line

dd

Delete current line

:d

Delete current line

Modes

Vi has two modes insertion mode and


command mode. The editor begins in
command mode, where the cursor
movement and text deletion and pasting
occur. Insertion mode begins upon
entering an insertion or change command.
[ESC] returns the editor to command
mode (where you can quit, for example by
typing :q!). Most commands execute as
soon as you type them except for "colon"
commands which execute when you press
the ruturn key.

Yanking Text

yy

Yank the current line

:y

Yank the current line

Cheatographer

Cheat Sheet

Sponsor

Eric Grivilers (ericg)


cheatography.com/ericg

Published 24th February, 2012.


Updated 21st February, 2014.
Page 1 of 2.

Measure your website readability!


www.readability-score.com

VI Editor Cheat Sheet


by Eric Grivilers (ericg) via cheatography.com/639/cs/270/

Changing text

Ranges

Change to the end of the line

:n,m

Range - Lines n-m

cc

Change the whole line

:.

Range - Current line

guu

lowercase line

:$

Range - Last line

gUU

uppercase line

:'c

Range - Marker c

Toggle upp and lower case

:%

Range - All lines in le

:g/pattern/

Range - All lines that contain


pattern

Putting text

p
P

Put after the position or after the


line
Put before the poition or before the
line

Files

mc

Set marker c on this line

`c

Go to beginning of marker c line.

'c

Go to rst non-blank character of


marker c line.

Search for strings

/string

Search forward for string

?string

Search back for string

:r le

Read le in after line


Go to next le

:p

Go to previous le

:e le

Edit le

!!program

Replace line with output from


program

Other

Join lines

Repeat last text-changing command

Undo last change

Undo all changes to line

Search for next instance of string

Write to le

:n

Markers

:w le

Search for previous instance of


string

Replace

:s/pattern/string/ags

Replace pattern with


string according to ags.

Flag - Replace all


occurences of pattern

Flag - Conrm replaces.

&

Repeat last :s command

Cheatographer

Cheat Sheet

Sponsor

Eric Grivilers (ericg)


cheatography.com/ericg

Published 24th February, 2012.


Updated 21st February, 2014.
Page 2 of 2.

Measure your website readability!


www.readability-score.com