1 / 18

VI EDITOR

VI EDITOR . University of Mississippi. Vi Editor. What is Vi ? Vi is a screen based editor. The screen of your terminal will act as a window into the file you are editing. Most commands to Vi move the cursor around the file . Faster (than pico ) for those who can type

vern
Télécharger la présentation

VI EDITOR

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VI EDITOR University of Mississippi

  2. Vi Editor • What is Vi ? • Vi is a screen based editor. • The screen of your terminal will act as a window into the file you are editing. • Most commands to Vi move the cursor around the file. • Faster (than pico) for those who can type • Available standard on most Unix systems

  3. Vi Editor • Starting the Vi editor • vi lets you create new files or edit existing files. • Command to start Vi : vi • Open existing (or create new) file in vi: vi example1

  4. Vi Editor • Modes of Operation • Command Mode Allows the entry of commands to manipulate text Commands are usually one or two characters long • Insert Mode Puts anything you type on the keyboard into the current file

  5. Vi Editor • Modes of Operation • Command Mode Allows the entry of commands to manipulate text Commands are usually one or two characters long • Insert Mode Puts anything you type on the keyboard into the current file

  6. Vi Editor • Vi starts in command mode by default • Most commonly used commands to get into insert mode are a and i • Once in insert mode, you get out of it by hitting the Esc key

  7. Vi Editor • From within vi: Hit i key to enter edit Insert Mode Type This is EASY. Then hit the escape key, for Command Mode

  8. Vi Editor • Saving files and exiting the Vi editor • :qQuit the editor • :q!Quit the editor without saving the changes to the file. • :w Save the file you are editing • ZZThe editing buffer is written to the file only if any changes were made. • :wq :- Same effect as ZZ

  9. To ensure you are in command mode: Hit the Esc key twice. To save your file: Type :w to write (save) the file. To save your file under a different name: Type :w example2 To save your file and quite: Type :wq

  10. Vi Editor • How to type commands in command mode [count] command [where] count : Its a number where : Specifies how many lines or how much of the document the command affects. It can also be any command that moves the cursor.

  11. Vi Editor • Moving from Command to Insert Mode • a Enter insert mode; the characters typed will be inserted after the current cursor position. If a count is specified, then the inserted text will be repeated that many times • i Enter insert mode, the characters typed will be inserted before the current cursor position. If a count is specified, the inserted text will be repeated that many times o Enter insert mode; will start a new line beneath current line.

  12. Vi Editor • Moving the cursor, in Command Mode h move cursor to the left l move cursor to the right j move cursor up k move cursor down Use vi to edit example2 to have these 2 lines:This is not hard.This is VERY easy.This is not hard at all.

  13. Vi Editor • Some simple Vi Commands • r replace one character under the cursor. Specify count to replace that many characters. • R Starting from the current cursor position, replace the characters with the one typed on the keyboard • x Delete character under the cursor. Count specifies how many characters to delete Practice these commands to further edit example2

  14. Vi Editor • Cutting text • d^ Deletes from current cursor position to the beginning of the line • d$ Deletes from current cursor position to the end of the line • Dw Deletes from current cursor position to the end of the word • dd Deletes one line from current cursor position. Specify count to delete many lines.

  15. Vi Editor • Yanking and Pasting • yl yank a single character. Specify count to yank more characters • yw yank a single word. Specify count to yank more words • yy yank a single line. Specify count to yank more lines • p paste the text that was either deleted or yanked previously m mark the current line

  16. Practice Yanking, Deleting, and Pasting Lines of Text Use vi to create a new file: example3, with these lines: One Two Three Four Five Six Seven Eight Nine ten Then, from command mode, enter :wqto save the file

  17. Vi Editor • To go to a specific line in the file :linenumber • To go to the last line in the file :G • String Search • /[pattern] : search forward for the pattern • ?[pattern] : search backward for the pattern • To undo the last command: • u

  18. More practice Use vi to edit existing file: example3 …

More Related