You are on page 1of 5

12/02/2015

viEditorCommands

viEditorCommands
Quicklinks...
GeneralStartup
Counts
CursorMovement
ScreenMovement
Inserting
Deleting
CopyingCode
PutCommand
FindCommands
MiscellaneousCommands
LineEditorMode
exCommands
Substitutions
ReadingFiles
WriteFile
Moving
ShellEscape

GeneralStartup

Tousevi:vifilename

Toexitviandsavechanges:ZZor:wq

Toexitviwithoutsavingchanges::q!

Toentervicommandmode:[esc]

Counts
Anumberprecedinganyvicommandtellsvitorepeat

thatcommandthatmanytimes.

CursorMovement

hmoveleft(backspace)

jmovedown

kmoveup

lmoveright(spacebar)

[return]movetothebeginningofthenextline

$lastcolumnonthecurrentline

http://www.cs.rit.edu/~cslab/vi.html

1/5

12/02/2015

viEditorCommands

0movecursortothefirstcolumnonthe

currentline

^movecursortofirstnonblankcolumnonthe

currentline

wmovetothebeginningofthenextwordor

punctuationmark

Wmovepastthenextspace

bmovetothebeginningofthepreviousword

orpunctuationmark

Bmovetothebeginningofthepreviousword,

ignorespunctuation

eendofnextwordorpunctuationmark
Eendofnextword,ignoringpunctuation
Hmovecursortothetopofthescreen
Mmovecursortothemiddleofthescreen
Lmovecursortothebottomofthescreen

ScreenMovement
Gmovetothelastlineinthefile
xGmovetolinex
z+movecurrentlinetotopofscreen
zmovecurrentlinetothemiddleofscreen
zmovecurrentlinetothebottomofscreen
^Fmoveforwardonescreen
^Bmovebackwardoneline
^Dmoveforwardonehalfscreen
^Umovebackwardonehalfscreen
^Rredrawscreen

(doesnotworkwithVT100typeterminals)
^Lredrawscreen

(doesnotworkwithTelevideoterminals)

Inserting
rreplacecharacterundercursorwithnext

charactertyped
Rkeepreplacingcharacteruntil[esc]ishit
http://www.cs.rit.edu/~cslab/vi.html

2/5

12/02/2015

viEditorCommands

iinsertbeforecursor
aappendaftercursor
Aappendatendofline
Oopenlineabovecursorandenterappendmode

Deleting

xdeletecharacterundercursor

dddeletelineundercursor

dwdeletewordundercursor
dbdeletewordbeforecursor

CopyingCode
yy(yank)'copies'linewhichmaythenbeputby

thep(put)command.Precedewithacountfor

multiplelines.

PutCommand
bringsbackpreviousdeletionoryankoflines,

words,orcharacters
Pbringbackbeforecursor
pbringbackaftercursor

FindCommands

?findsawordgoingbackwards

/findsawordgoingforwards

ffindsacharacteronthelineunderthe

cursorgoingforward
Ffindsacharacteronthelineunderthe

cursorgoingbackwards
tfindacharacteronthecurrentlinegoing

forwardandstoponecharacterbeforeit

Tfindacharacteronthecurrentlinegoing

backwardandstoponecharacterbeforeit

repeatlastf,F,t,T

http://www.cs.rit.edu/~cslab/vi.html

3/5

12/02/2015

viEditorCommands

MiscellaneousCommands

repeatlastcommand

undoeslastcommandissued

undoesallcommandsononeline

xp

deletesfirstcharacterandinsertsafter
second(swap)

joincurrentlinewiththenextline

^G

displaycurrentlinenumber

ifatoneparenthesis,willjumptoitsmate

mx

markcurrentlinewithcharacterx

'x

findlinemarkedwithcharacterx

NOTE:Marksareinternalandnotwrittentothefile.

LineEditorMode

Anycommandsformthelineeditorexcanbeissued

uponenteringlinemode.

Toenter:type':'

Toexit:press[return]or[esc]

exCommands

Foracompletelistconsultthe

UNIXProgrammer'sManual

READINGFILES

copies(reads)filenameaftercursorinfile

currentlyediting

:rfilename

WRITEFILE

:w

savesthecurrentfilewithoutquitting

:#

movetoline#

:$

movetolastlineoffile

MOVING

http://www.cs.rit.edu/~cslab/vi.html

4/5

12/02/2015

viEditorCommands

SHELLESCAPE

executes'cmd'asashellcommand.

:!'cmd'

http://www.cs.rit.edu/~cslab/vi.html

5/5

You might also like