Tuesday, October 9, 2012

Vi Editor shortcuts

dd
delete the line
u
Undo
U
Undo all changes on a line
CTRL+R
Redo
/
Search
n
Search the same phrase again
N
Search in the opposite direction
?
Search in backward direction(use instead of /)
CTRL+O
Go back to where we came from
CTRL+I
Go to newer position
%
Move the cursor to the matching parenthesis
:s/old/new/ge
Replace all occurrences of old with new
ge in above command
Find every occurrence in the whole file, with a prompt whether to substitute or not
CTRL+G
Displays your current location in the file and file status
G
Moves to the end of the file
<number>G
Moves to that line number
gg
Moves to first line
:!<command>
To execute a shell command from within the shell
v
Select line
:r!dir
Reads the output of the command and put it below cursor
y ->
Copies text (y -yank)
p ->
Pastes text (p -paste)
:set xxx

Sets search option xxx where options are:
ic :- ignore case
is  :- incsearch -->show partial search
h|s :- highlight all matching phrases

No comments:

Post a Comment