HOME

  Solaris Forum  

  Newsletter  

 Tell a Friend

  Bookmark

Google Web adminschoice.com 
redarrow1.gif (101 bytes)redarrow1.gif (101 bytes) Day Light Saving Change in USA - Summary of changes with links to patches and information.
redarrow1.gif (101 bytes)redarrow1.gif (101 bytes) Application Monitoring - Challenges , best practices and implementation of application monitoring is discussed.
redarrow1.gif (101 bytes)Unix Commands - A quick reference to commonly used unix commands .
redarrow1.gif (101 bytes)Solaris Network Configuartion - Simplified : Quick reference to setting up network in Solaris system
Performance Monitoring -  iostat , vmstat & netstat - Introduction to performance monitoring tools with example and command  syntax.
crontab in Unix - A Quick Reference to setting up and using cron jobs in unix .
Veritas Volume Manager-1
Using vxdiskadm to add &  manage disks & disk groups .
Veritas Volume Manager-2
Using vxassist to create ,configure &  manage volumes .
Admin's Guide to Solstice Disk Suite: Complete practical reference including root mirroring and trouble shooting.
Securing Solaris
A few suggestions to make your Solaris system secure from internal and external intrusion.
 
Solaris Installation
Step by step guide to Solaris Installation.
Jumpstart Server
Network  installation of Solaris over one or multiple systems. 
Booting Process
Details of Solaris  booting process. 
Booting Problems in Solaris
Common booting related error messages and their possible solution
DNS Server
Setting up DNS server
Trouble Shooting DNS  Some of the configuration and nslookup related errors explained.
NIS+
Server , Clients setup and commands. 
OpenBoot Parameters
Reference table of important parameters and their values.
Solaris Error Messages
Alphabetical listing of common Solaris Error Messages and their explanation
Checking & Repairing File systems with fsck   fsck operation ,syntax and explanation of some common error messages
Vi Quick  Reference   
vi basics for  reference
explanations.
 
Open Directory   
Unix , Solaris Administration 
Sun.com   
BigAdmin
 
 
 
FAQs
unix , unix programming , VI  ,Sendmail  , Bind
ssh ,BASH ,Security, Secure unix programming, Unix socket 
SCSI
Solaris 2Solaris x86  ,NIS+ FreeBSD ,RedHat , HPUX
:
Unix
Unix History and timeline ,
Overview of the UNIX 
Microsoft Windows NT Server 4.0 versus UNIX
Overview of Unix Commands 
Unix for advance Users ,
Unix Bourne Shell Guide with Ksh ,
Korn Shell
BASH reference Guide
:
Solaris Documentation
Solaris 7 System Administration Collection
Solaris 8 System Administrator Collection
Solaris 9 System Administartion Collection
Creating Solaris Packages
Multibooting Solaris 
:
Sun
Sun System Handbook
Sun Hardware Info.
:
Documentation Home
Sun , BSD  ,Linux ,Hp,Veritas
:
Patches & Softwares
Solaris Patches , 
Solaris Freeware
GNU Software
big brother  , 
webmin .com
bugzilla.org
:
Certification Info 
Sun  ,Red Hat , HP
 
vi editor Quick reference

Table of Contents

  1. Introduction
  2. Requirement
  3. Creating , opening files in vi 
  4. Modes in vi editor
  5. Saving & exiting the vi editor
  6. vi commands , quick reference
  7. Next Steps
 
 
Introduction:
__________

vi  pronounced as " vee eye " is a unix editor available on  almost all the unix  operating systems , solaris , bsd ,aix , hpux etc.

This document is a quick reference to vi editor and will be of help if your are new to unix , learning unix  or just refreshing your vi knowledge after a few years.

 
Requirements:
____________
In order to work correctly the vi need correct terminal type (TERM) setting  .The TERM setting depends on the type of terminal you have . Commonly used TERM types are vt100 , vt220 and ansi .  In most cases vt100 will  work  fine . In case vi is not able to understand the TERM you have given, it starts in open mode giving you a line by line display .
Generally TERM is taken from .profile or /etc/profile  but can be set at the command line as :
$TERM=vt100
$export TERM    

echo $TERM will display the current TERM set.

Create new file or Open existing file in vi
__________________________________
vi without any file name will open a  new file where you can enter the text and edit but while coming out you will be asked to enter a valid file name to save the text.
vi with a  file name as argument will open that file for editing  if the file already exists it opens it otherwise it creates a new file by the argument.
Example :  $vi  testfile
Creates or opens the existing file called testfile
 
Modes in vi
____________
 vi operates in following  two modes :
i. ) Command Mode : After a file is opened it is opened  in command mode ,that is , input from the keyboard will be treated as vi commands  and you will not see the words you are typing on the screen .
 
 ii.) Insert Mode: To enter the text you have to put vi in insert  by pressing 'i' or 'a'  after which you can add the text and whatever is being type will be seen on the screen. . To switch between these mode Esc key is used .   Esc i  (text mode)  Esc (command mode) 
 
Saving & Exiting  vi editor
______________________

 You can exit vi in different ways :

1.) Quit without saving : If you don't want to save the work :q  will take you out without saving your editing in vi.
2.) Write & quit : . Simple :w saves the current file but don't exit. For save and quit  :wq is used in vi. 
3.) Forced Quite : An ! (Exclamation sign at the end of  exit commands ( :q! , :wq! )  causes a forced quit from vi  after ignoring editing (for :q!)  or writing (for :wq!) all the changes..
 

 

 
 

 

 

 

 

 

 

 

 

 

 

InventioConsulting
Offering Unix , Solaris & IT Training Services throughout the UK.
 
 

vi commands , quick reference

Moving Cursor in File
Left    h
Right i
Up k
Down j
Line
Beginning ^ or B
end $

Sentance :

 Next sentance )
Previous sentance (
Paragraph
Next }
Previous  {

file

Go to end of file :$
on chacter forword :w
One word forword :W
go to a line number :line_number
display file info .

^g

Inserting and appending text :
inserts text to the left of  cursor i
nserts in the beginning of line  I
appends text to right of cursor a
appends to the end of line A

Adding new line

add a new line below the current line o
adds a new line above the current line. O
deleting the text :
deletes text above the text x
deletes text character on  right of cursor X
deletes line 20 20d
deletes current line dd
 delete till end of current line. D
Replacing a character & word
 replace the character above the cursor. r
replces characters until Esc is pressed. R
replaces the word from cursor to the end indicated by $ sign . cw
 replaces till end of line. C
Substitute
subistutes current charcater. s
substitutes entire line. S
Undo the last change
undo last change. u
undo changes to the current line. U
Copy and pasting lines
copys the current line into buffer. yy
copies 5 lines from the current line. 5yy
pastes the current buffer. p
Searching
Searches for the word name in the file :/name  
n continues search forward. n
N searches backwards N
Saving
saves the text does not quit. :w
 saves & quit the editor . :wq!
save ZZ
Quit without saving q!
Search & Replace s/<search-string>/<replace-string>/g  .
Repeating  last command .
Recovering a unsaved vi file.
vi -r  filename 
 

7. Next Steps :

vi editor is all time favorite for the unix admins and there are some books available if you are interested in exploring the more powers of vi editor. The editor is also covered in system administration books so you may find a chapter devoted to vi editor in most of the unix system administration books.

You can purchase unix administration or vi editor books from amazon.com online using the display panel below.

 

 

click here to send your feedback about this article .

Copyright © 2000-2005 , Adminschoice.com