Powered By Blogger

Wednesday, 14 November 2012

Basic commands for the Linux vi Editor

CommandDescription
iinsert mode, (ESC to exit insert mode) allows text to be entered on the screen
aAppend to right mode
/wordMove to the occurrence of "word"
nLocate the next occurrence
wAdvance to the next word
eAdvance to the next end of a word
bMove to the previous word
3bMove backward 3 words
yyCopy line (then move cursor and use p to paste after current cursor line)
dddelete line
3dddelete 3 lines
DDelete remainder of a line
dwDelete word
xDelete character
oOpen space for new line below the cursor line
OOpen a line above the cursor
CTRL-wMove back a word in append mode
uUndo last
UUndo all changes to current line
.In command mode, repeat the last text changing the command on the current line
:w newfilenamesave the file to newfilename from the command mode
:wqsave and quit
:q!quit without saving
rreplace then typa a character ot be replaced with r then return to break up a line
Jjoin 2 lines
ssubstitute (sentence) typed text over a character, ESC when done
cwchange word
cchange part of a line from the cursor to the end of the line
ccsubstitute new text for aline, ESC when done
hmove the cursor back one space
Hmove the cursor to the highest line on the screen
Lmove the cursor to the lowest line on the screen
Mposition the cursor at the midpoint on the screen
Glast line in the file
0 (zero)Move the cursor to the beginning of the line it is on
view filenameOpen a file for viewing only
set numberTurn on line numbers
set nonumberTurn off line numbers
Options
autoindent(ai ctrl-d to move to the left
showmatchmatch brackets and parenthesis
tabstop=4
wrapmargine(wm)when line is wrapped (80-value)
:2 copy 4Place a copy of line 2 after line 4.
:1,4 copy 7(lines 1-4)
:nAccess the next file for editing

No comments:

Post a Comment