0% found this document useful (0 votes)
169 views

VI Editor Commands PDF

This document provides an overview of commands for the vi text editor. It describes general startup commands like opening and saving files. It also covers cursor movement, screen movement, inserting and deleting text, searching, and ex commands for reading, writing, and moving within files. The vi editor allows editing from both command mode using keyboard shortcuts and line editor mode using ex commands.

Uploaded by

freidyfriends
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views

VI Editor Commands PDF

This document provides an overview of commands for the vi text editor. It describes general startup commands like opening and saving files. It also covers cursor movement, screen movement, inserting and deleting text, searching, and ex commands for reading, writing, and moving within files. The vi editor allows editing from both command mode using keyboard shortcuts and line editor mode using ex commands.

Uploaded by

freidyfriends
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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