Navigating through vi/vim editor

The vim editor

Inserting text
COMMANDACTION
iInsert text before current cursor position
aAppend text after current cursor position
AAppend text at the end of the current line
oOpen new line below the current line
OOpen new line above the current line
Navigating in vi
COMMANDACTION
left arrow / hmove left 1 character
right arrow / lmore right 1 character
up arrow / kmove up 1 line
down arrow / jmove down 1 line
$move to the end of current line
0move to beginning of current line
Deleting text
COMMANDACTION
xdelete character at current cursor position
dwdelete word or part of word to the right of cursor
dddelete current line
DDelete current line starting from the current cursor position
Undoing and repeating
COMMANDACTION
uundo the last command
. (dot)repeat the last command
Search and replace text
COMMANDACTION
/[string]Search forward for string
?[search]Search backward for string
nFind next occurrence of string
Nfind previous occurrence of string
:%s/old/newSearch and replace first occurrence of string old with string new
:%s/old/new/gSearch and replace all occurrence of string old with string new
cwChange the word staring from current cursor position
rReplace character at current cursor position
RReplace/overwrite text on current line
Copying and Pasting text
COMMANDACTION
ywYank the current word in buffer
yyYank the current line in buffer
pPaste the yanked data below the current line
PPaste the yanked data above the current line
Saving and quiting
COMMANDACTION
:wWrite change into the file without quitting
:w!write change into the file even if you are not owner of the file
:wqwrite change into the file and quit
:wq!write change into the file and quit even if you are not owner of the file
:qquits when no changes are made
:q!quits without saving the changes made

0 comments:

Post a Comment