Vi EditorAgendaText Editor in LinuxStarting vi / vimFirst look at viFirst look at vimvi modeSwitch to insert modeSwitch to insert mode (CONT.)Delete and block operation -- cut, copy and pasteundoSearch in textSave and exitMore readingVi EditorTA for ITIS3100: Xu [email protected]•Text Editor in Linux•How to use viStart viFirst look at vivi modeSwitch to insert modecopy, cut and pasteundosearchsave and exit•ReferenceText Editor in Linux•We have several choices:vivimgedit (for GNOME) like the NotePad in WindowsAnd many, many othersStarting vi / vim•Use vi to open an already existing file by typing vi file-name •Create a new file by typing vi new-file-nameFirst look at viFirst look at vimvi mode•vi has two modes: command mode insert mode •In command mode, the letters of the keyboard perform editing functions (like moving the cursor, deleting text, etc.). To enter command mode, press the escape <Esc> key. •In insert mode, the letters you type form words and sentences. Unlike many word processors, vi starts up in command mode.Switch to insert mode•Type the following key:i -- to insert mode at course positiona -- to insert mode where course back a characterSwitch to insert mode (CONT.)I -- to insert mode where course jump to the line headA -- to insert mode where course jump to the line endo -- to insert mode and begin a new line under course positionO -- to insert mode and begin a new line before course positions -- to insert mode and delete the character at course positionS -- to insert mode and delete the line at course positionDelete and block operation -- cut, copy and paste•Switch to command mode, pressing the escape <Esc> key. Type v, switch to block operationmove course to select blockc to cut, y to copyp to paste the block to right position of course•Switch to command mode, pressing the escape <Esc> key. Use shortcuts for deletedd -- delete the current linedw -- delete the current wordundo•Switch to command mode, pressing the escape <Esc> key. :u -- undo last operation:e! -- give up all operations and begin edit againSearch in text•vi supports to search and find a text in the whole file•Switch to command mode, pressing the escape <Esc> key. /keyword -- to search forward for the keyword?keyword -- to search backward for the keyword•type n on the keyboard to find the nextSave and exit•Switch to command mode, pressing the escape <Esc> key. :w -- save file:q -- no change and quit:wq -- save file and quit:q! -- force to quit, no matter change file or not:x –- save file and exit viMore
View Full Document