solaris vi editor commands

3
Navigation: Key Use j(or down arrow) To move the cursor to the next line (move down) k(or up arrow) To move the cursor to the previous line (move up) h(or left arrow) To move left one character l(or right arrow) To move right one character H To move the cursor to current page beginning of the first line. G To move the cursor to current page beginning of the last line. b To move the cursor previous word first character e To move the cursor next word last character w To move the cursor to next word first character ^ Go to beginning of line 0 Go to beginning of line $ Go to the end of the line CTRL+F forward 1 screen CTRL+B backward 1 screen CTRL+D down (forward) 1/2 screen CTRL+U up (backward) 1/2 screen Copy & Paste: Key Use y+w To copy rest of the word from current cursor position. n+y+w To copy n number of words from the current cursor position. y+y To copy a line n+y+y To copy n lines p(lowerCase) To paste a copied words/lines after the current position of the cursor P(uppercase) To paste a copied words/lines before the current position of th e cursor Deletion: Key Use x deletes a single character n+X To delete n number of characters from the cursor position in a line. d+w To delete rest of a word from current cursor position n+d+w To delete n number of words from the cursor position in a line d$ Delete rest of line from current cursor position D Delete rest of line from current cursor position d+d To delete an entire line n+d+d To delete n lines from current cursor position Few More Important Command Mode commands: Key Use u Undo changes (only one time) U Undo all changes to the current line ~ To change the case of the letter ZZ Saves the changes and quits the vi editor Input or Insert Mode: In this mode we can insert text into the file. We can ente r the insert mode by pressing following keys in command mode: Key Use i Inserts the text before the cursor I Inserts the text at the beginning of the line o Opens a new blank line below the cursor

Upload: techfolkcmr

Post on 13-May-2017

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solaris Vi Editor Commands

Navigation:KeyUsej(or down arrow) To move the cursor to the next line (move down) k(or up arrow) To move the cursor to the previous line (move up) h(or left arrow) To move left one characterl(or right arrow) To move right one characterH To move the cursor to current page beginning of the first line.G To move the cursor to current page beginning of the last line.b To move the cursor previous word first charactere To move the cursor next word last characterw To move the cursor to next word first character^ Go to beginning of line 0 Go to beginning of line$ Go to the end of the lineCTRL+F forward 1 screenCTRL+B backward 1 screenCTRL+D down (forward) 1/2 screenCTRL+U up (backward) 1/2 screen Copy & Paste:Key Usey+w To copy rest of the word from current cursor position. n+y+w To copy n number of words from the current cursor position.y+y To copy a linen+y+y To copy n linesp(lowerCase) To paste a copied words/lines after the current position of the cursorP(uppercase) To paste a copied words/lines before the current position of the cursor

Deletion:KeyUsex deletes a single character n+X To delete n number of characters from the cursor position in a line.d+w To delete rest of a word from current cursor positionn+d+w To delete n number of words from the cursor position in a lined$ Delete rest of line from current cursor positionD Delete rest of line from current cursor positiond+d To delete an entire linen+d+d To delete n lines from current cursor position

Few More Important Command Mode commands:KeyUseu Undo changes (only one time) U Undo all changes to the current line ~ To change the case of the letterZZ Saves the changes and quits the vi editor

Input or Insert Mode: In this mode we can insert text into the file. We can enter the insert mode by pressing following keys in command mode:

KeyUsei Inserts the text before the cursor I Inserts the text at the beginning of the line o Opens a new blank line below the cursor

Page 2: Solaris Vi Editor Commands

O Opens a new blank line above the cursora Appends text after the cursorA Appends the text after the liner replace the single character with another character R replace a entire lineEsc To return to command mode

Last line mode or Collan Mode : This is used for advance editing commands. To access the last line mode enter ":" while in command mode.

KeyUse: To get to collan mode(This need to be entered every time a user wants to use collan mode command):+set nu Shows line numbers:+set nonu Hides line numbers:+enter+n Moves the cursor to the n line:+/keyword To move the cursor to the line starting with the specific keyword:+n+d Deletes nth line:+5,10d Delete line from 5th line to 10th line:+7 co 32 Copies 7th line and paste in 32nd line:+10,20 co 35 Copies lines from 10th line to 20th line and paste it from 35th line

:+%s/old/new/g Searches old string and replaces with the new string:+q+! Quits vi editor without saving:+w Saves the file with changes by writing to the disk:+w+q Saving and exit the vi editor:+w+q+! Saving and quitting the file forcefullyESC To return back to the command mode

Using VI Command:vi options <file name>The options are discussed below:-r : To recover a file from system crash while editing.-R : To open a file in read only mode.

Viewing Files in Read Only Mode:view <file name>This is also used to open the file in read only mode. To exit type ':q' command.

Automatic Customization of a VI session:1. Create a file in the user's home directory with the name .exrc2. enter the set variables without preceding colon3. Enter each command in one line.VI reads the .exrc file each time the user opens the vi session.Example:#cd ~#touch .exrc#echo "set nu">.exrc#cat .exrcset nu#In the above example we have used set line number command. So whenever the user opens the vi session, line number is displayed.

Page 3: Solaris Vi Editor Commands

I know its nearly impossible to keep all the above commands in mind, even I don't have, but as we keep practicing, we will be knowing most of them.