1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display

Download 1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display

Post on 21-Dec-2015

216 views

Category:

Documents

4 download

Embed Size (px)

TRANSCRIPT

<ul><li> Slide 1 </li> <li> 1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display the text you are creating (or editing) one screen at a time </li> <li> Slide 2 </li> <li> 2 Using the vi Editor Called vi because it is visual it immediately displays on screen the changes that you make to text works in different modes Insert mode - lets you enter text Command mode - lets you enter commands to perform editing tasks </li> <li> Slide 3 </li> <li> 3 Using the vi Editor To create a new file in the vi editor, type vi and the name of the new file at the command prompt </li> <li> Slide 4 </li> <li> 4 Using the vi Editor When started, the vi editor is in command mode In order to insert text, you must issue the i command to enter insert mode Esc key will change vi from text mode to command mode You can repeat the line just entered with the repeat command (.) To edit what youve just typed, move the cursor with the various keyboard cursor movement keys </li> <li> Slide 5 </li> <li> 5 Using the vi Editor In insert mode, every character you type appears on the screen </li> <li> Slide 6 </li> <li> 6 Using the vi Editor The repeat command repeats the last insertion, or line. Now, edit the new line in order to create the next item </li> <li> Slide 7 </li> <li> 7 Using the vi Editor </li> <li> Slide 8 </li> <li> 8 Vi-Correcting text keys x Deletes the character specified by the cursor position dd Deletes the line specified by the cursor position u Undoes the most recent change U Undoes all the changes on the current line r Replaces a character that the cursor is on R Replaces characters starting from the cursor position, and changes vi to the text mode </li> <li> Slide 9 </li> <li> 9 Exit from vi editor Save - :w Save as different file - :w filename Save file and exit -- :wq filename Exit without saving file - :q! </li> <li> Slide 10 </li> <li> 10 practice </li> <li> Slide 11 </li> <li> 11 Using the vi Editor </li> <li> Slide 12 </li> <li> 12 Using the vi Editor Use the delete commands and the cursor movement keys to edit the text </li> <li> Slide 13 </li> <li> 13 Using the vi Editor </li> <li> Slide 14 </li> <li> 14 Using the vi Editor </li> <li> Slide 15 </li> <li> 15 Using the vi Editor The status line at the bottom of the screen displays information, including line- oriented commands and error messages </li> <li> Slide 16 </li> <li> 16 Using the vi Editor During text searches, you can replace, too. Use line-oriented commands in ex mode to perform this action </li> <li> Slide 17 </li> <li> 17 Using the vi Editor Saving a File and Exiting vi You should always save the file before exiting vi, otherwise changes are lost To save a file and continue working on it, type the :w (write) command While in command mode, use the :wq (write and quit) command to save and exit iv, or the :zz command to exit after saving </li> <li> Slide 18 </li> <li> 18 Using the vi Editor In vi, you can also: Add text from another file Leave vi temporarily to perform other UNIX tasks, then return to your file Change your display while editing, such as adding line numbering to help editing Copy, cut, and paste text to help editing Print text files Cancel an editing session </li> <li> Slide 19 </li> <li> 19 Using the vi Editor </li> <li> Slide 20 </li> <li> 20 Using the vi Editor </li> <li> Slide 21 </li> <li> 21 </li> </ul>