You are on page 1of 4

Know your VI EDITOR

The VI command line interface is available by typing ":" - Terminate with a carriage return.
Example
: help topic
If the exact name is unknown T!" completion will cycle through the various options given the
first few letters. #trl-d will print the complete list of possibilities.
^G
$isplays all the information regarding current file in the following format
%filename& line' of (total lines) -- x* col' +column number,
OPEN, SAVE & !IT
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 56 7uit
8 569 7uit and throw away changes
: 5w -ave
; 5w filename -ave as (filename)
< 5x -ave =7uit
> ?? -ave =7uit
"ORI#ONTA$ %OVE%ENT
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 -@ l .ight one character
8 A- h Beft one character
: C +?E./, "eginning of the line
; D End of the line
< w E F "eginning of next word
> e E E End of the next word
G b E " "eginning of previous E next word
H + E , "eginning of previous E next sentence
I J E K "eginning of current E next I2
VERTI&A$ %OVE%ENT
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 L Mp one line
8 N $own one line
: 2g up O" Mp one page
; 2g dn O3 $own one page
< +number,P Po to line number
SEAR&" ' SEAR&" ( REP$A&E
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 Estring 3ind string ahead of cursor position
8 Qstring 3ind string backwards
: n E 1 .epeat search ahead the cursor E "ackwards
; 5s E new E oldE .eplaces first match in current line
< 5s E new E oldEg .eplaces all matches in current line
> 5*sEnewEoldEg Plobal replace
G 5*sEnewEoldEgc Plobal replace at prompt
&O%PO!ND &O%%ANDS
-. '. #/00!1$ !#TI/1 2E.3/.0E$
4 dd $eletes one line
8 d:w $elete next : words
: dK $elete remainder of I2
; d, $elete remainder of line
< dC $eletes the current line till the cursor
> dD $eletes the current line from cursor to the end
G :-@ 0ove : chars right
H ;, 0ove ; sentences ahead
I 8b 0ove 8 words "ackwards
4C 48K 0ove 48 paragraphs ahead
44 . + dot , .epeat the last command
48 u Mndo
4: N Noin next line to end of current line
&!T & PASTE
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 yy Rank+select to copy, one line
8 <yy Ranking < lines
: p 2aste the yanked lines
Short)cut:
Rou can also select to copy lines using the mouse +in vi editor selecting a text is e6ual to
selecting and copy,.
To paste Sust go to the position and press the middle scroll button of the mouse. +.emember to
be in the insert mode while pasting,
*INDO*ING
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 5sp filename 1ew split frame window
8 Ow Poto next window
TA++ING
-. ' #/00!1$ !#TI/1 2E.3/.0E$
4 5set tabstepT' -et tab siUe to ' chars
8 O$ A-
: OT -@
; 5set auto indent
TO &"E&K T"E OPENING AND &$OSING O, PARENT"ESIS
2ress * + shift <, at a parenthesis position to check its beginning V closing.
*RAPPING TE-T
5set wmT' Fraps text after ' characters.
&ONVERT &ASE
. #onverts #ase of the character on the cursor
TO EDIT %!$TIP$E ,I$ES
/i 0ile1 0ile2 0ile3
:n Edit next file +file8,
:n Edit next file +file:,
:N Edit previous file+file 8,
:wn -ave changes and move to next file
:rew .ewind to the first file +file4,
TO GO TO A $INE
:4 takes u to line number '
or
In esc mode press 4( to move ' lines ahead.
A$IGNING 5O!R &ODE
4, export EWI1ITTXset swT;X ---- Frite this command in 6789:hrc67 This will set the
:hi0t wi;th e6ual to <.
8, execute command "89:h"
:, #ommand to Ri=ht Shi0t =roup o0 line:5
a, In vi command mode
b, move to first line of that group
c, ma ----------------------- This will set marker to first line of the group+ as cursor is on
first line of that group, and marker name will be "9". Rou can use any alphabet in this command.
d, move to last line of that group
e, @Xa -------------- This right shifts the group of lines by shift width ;.
;, #ommand to $e0t Shi0t =roup o0 line:5
a, In vi command mode
b, move to first line of that group
c, ma ----------------------- This will set marker to first line of the group+ as cursor is on
first line, and marker name will be "9". Rou can use any alphabet in this command.
d, move to last line of that group
e, AXa ----------- This left shifts the group of lines by shift width ;.
<, Ri=ht :hi0tin= :in=le line5
a, In vi command mode
b, move to that line.
c, @@ ----------------- This right shifts the line by shift width by ;.
>, $e0t :hi0tin= :in=le line5
a, In vi command mode
b, move to that line.
c, AA ------------------ This left shifts the line by shift width by ;.
TAGGING
This functionality allows one to Sump between files to locate subroutines.
ct9=: >7h >7c This creates a file names "tags".
Edit the file using /i.
/n vi command line5 :t9= :u8routine?n9@e This will Sump from your current
file to the file containing the subroutine. +short form :t9 :u8routine?n9@e ,
"y cursor position5 ctrl)A 2lace cursor on the first character of the subroutine
name and press ctrl)A This will Sump to the file containing the subroutine.
In all cases you will be entered into the correct file and the cursor will be positioned at the
subroutine desired.
If it is not working properly look at the "tags" file created by ct9=:.
Tag 1otes 5
! proSect may have a tags file which can be added and referred to by5 ::et t9=:Bt9=:C
'9;':rc'proDect17t9=:
! "Y" must separate the file names.
::et 9utowrite will automatically save changes when Sumping from file to file otherwise
you need to use the :w command.

You might also like