vi manual for HP-UX
vi manual for SunOS
vi manual for AIX

TIPS
Search
search for string "john" or "joan"
/jo[ha]n
search for strings "the", "theatre" or "then"
/\< the
search for strings "the" or "breathe"
/the\>
search for word "the"
/\< the\>
search for all 4 lettered words
/\< ....\>
search for string "pay up" in the forward direction
/pay up
search for string "pay up" in the backward direction
?pay up
Search and Replace
replace begining of every line with "hello"
:%s/^/hello/g
replace end of every line with "Harry"
:%s/$/Harry/g
replace every "onward" with "forward"
irrespective of case
:%s/onward/forward/gi
search for "Ted Bundy" and replace "Bundy" with "Danson"
but do not change any "Al Bundy"
:g/Ted Bundy/s/Bundy/Danson/g
remove trailing blanks
:%s/ *$//g
Replace the following lines
create user user103 identitified by user103
create user user104 identitified by user104
create user user105 identitified by user105
with
grant connect to user103
grant connect to user104
grant connect to user105
:%s/^.*\(user.*$\)/grant connect to \1/g
deletes every line that contains "string"
:g/string/d
deletes every line that does not contain "string"
:v/string/d
changes first occurence of "Bill" in current line to "Steve"
:s/Bill/Steve/
changes every occurance of "Bill" in current line to "Steve"
:s/Bill/Steve/g
changes every occurance of "Bill" in all lines to "Steve"
:%s/Bill/Steve/g
changes every occurance of "Bill" in all lines to "SteveBillAndOthers"
:%s/Bill/Steve&AndOthers/g
Convert Case
turn all letters to uppercase
:%s/.*/\U&
turn all letters to lowercase
:%s/.*/\L&
turn the first letter of all words to uppercase
:%s/\<./\u&/g
turn the first letter of all words to lowercase
:%s/\<./\l&/g
turn the first letter of all lines to uppercase
:%s/.*/\u&
turn the first letter of all lines to lowercase
:%s/.*/\l&
Read / Write from another file
Write lines 1 through 10 from the current file to outfile
:1,10 w outfile
Write lines 1 through 10 from the current file to outfile forcefully
:1,10 w! outfile
Append lines 1 through 10 from the current file to outfile
:1,10 w >> outfile
Read from infile to the current file below current line
:r infile
Read from infile to the current file below line 23 of current file
:23r infile
Open a file called hitlist from unix prompt using vi
and then have cursor automatically at line 62
vi +62 hitlist
Open a file called hitlist from unix prompt using vi
and then have cursor automatically at line containing Bugs Moran
vi +/"Bugs Moran" hitlist
Interact with unix
execute the command "pwd" on unix and return to vi
:!pwd
execute the command "pwd" on unix and capture
the output into the file being edited
!!pwd
exit out of the file being edited into unix temporarily
:sh
return back to the file from unix
$exit
Setting line numbers
set line numbers to visible
:se nu
set line numbers to invisible
:se nonu
Advanced commands
copy lines 1 through 5 after line 35
:1,5t35
copy lines 1 through 5 at the end of the file
:1,5t$
remove null lines in the file
:g/^$/d
align all lines
:%!fmt
align all lines starting from current location downward
!}fmt
align next 5 lines
5!!fmt
Append "son" to "john" on the first 5 lines
:1,5s/john/&son/g
Double the number of spaces between the words
:%s/ */&&/g
Delete everything after and including the colon.
:s/^\(.*\):.*/\1/g
Swap the words either side of the colon.
:s/\(.*\):\(.*\)/\2:\1/g
move down 3 lines from the current line
:+3
move up 7 lines from the current line
:-7

Get vi for windows95/NT

Any comments or suggestions, email me

The Unix Webring: [Home] [Next] [Prev] [Random] [List]



The Unix System Administrator Webring:
[Home] [Next] [Prev] [Random] [List]




-----