Sie sind auf Seite 1von 3

Summary of vi Commands

Starting vi file vi R file view file Stopping ZZ :q! save data and stop stop without saving data start vi, edit specified file start vi read-only, edit specified file start vi read-only, edit specified file

Recovering After System Failure vi r vi r file Controlling the !" :set num#er :set nonum#er $oving the Cursor h or <left> or <backspace> % or <down> & or <up> l or <right> or <space> ' ( <return> ) * ! w e # + , . / 0 1 2 $ " move move move move move move move move move move move move move same same same move move move move move move move cursor one position left cursor one position down cursor one position up cursor one position right cursor to beginning of previous line cursor to beginning of next line cursor to beginning of next line cursor to beginning of current line cursor to end of current line cursor to first non-space/tab in current line cursor forward to first character of next word cursor forward to last character of next word cursor forward to first character of prev' word as w; ignore punctuation as e; ignore punctuation as #; ignore punctuation forward to next sentence beginning backward to previous sentence beginning forward to next paragraph beginning backward to previous paragraph beginning cursor to top line cursor to middle line cursor to last line isplay redisplay the current screen display internal line numbers do not display internal line numbers display names of files that can be recovered start vi, recover specified file

$oving 3hrough the ,diting -uffer !F !n!F n!! !4 n! n!4 move move move move move move move move down one screenful up one screenful down n screenfuls up n screenfuls down half a screenful up half a screenful down n lines up n lines

Searching for a 5attern 6rexp 6 7rexp 7 n 8 search repeat search repeat repeat repeat forward for a specified regular expression forward search for previous pattern backward for specified regular expression backward search for previous pattern last 6 or 7 command, same direction last 6 or 7 command, opposite direction

Special Characters to 4se in Regular ,9pressions : ; ! * <= <> ? @ ?! @ < "ine 8um#ers nA BA A :map g BA Cnserting i a C A o D $a&ing Changes r R s C cc S cmove E Replacing a 5attern "s6pattern6replace6 "lines6pattern6replace6 "line,,lines6pattern6replace6 "Fs6pattern6replace6 4ndoing or Repeating a Change u 4 : undo last command that modified the editing buffer restore current line repeat last command that modified the editing buffer substitute, substitute, substitute, substitute, current line specified line specified range all lines replace exactly # character $do not enter input mode% replace by typing over replace # character by insertion replace from cursor to end of line by insertion replace entire current line by insertion replace entire current line by insertion replace from cursor to move by insertion change the case of a letter change change change change change change to to to to to to insert insert insert insert insert insert mode" mode" mode" mode" mode" mode" insert before cursor position insert after cursor position insert at start of current line insert at end of current line open below current line open above current line !ump to line number n !ump to first line in editing buffer !ump to last line in editing buffer define macro so g will be the same as BA match any single character except newline match ero or more of the preceding characters match the beginning of a line match the end of a line match the beginning of a word match the end of a word match one of the enclosed characters match any character that is not enclosed interpret the following symbol literally

Controlling the "ength of "ines r<return> G :set wmHn replace a character with a newline !oin lines auto line break within n positions of right margin

eleting 9 I dd dmove dA dBA "lined "lineJlined Copying the "ast 5 p 9p deep ddp Copying and $oving "ines :linecotarget :lineJlinecotarget "linemtarget "line,linemtarget ,9ecuting Shell Commands :!command :!! :sh :!csh Reading ata insert insert insert insert insert ata contents of file after specified line contents of file after current line output of command after specified line output of command after current line words that begin with specified pattern pause pause pause pause vi, vi, vi, vi, execute execute start a start a specified shell command previous shell command shell &-'hell copy copy move move specified specified specified specified line; insert below target range; insert below target line; insert below target range; insert below target eletion copy last copy last transpose transpose transpose deletion; insert after/below cursor deletion; insert after/above cursor two characters two words $start to the left of first word% two lines delete delete delete delete delete delete delete delete delete character at cursor character at left of cursor from cursor to end of line the entire current line from cursor to move from cursor to end of editing buffer from cursor to beginning of editing buffer specified line specified range

"liner file "r file "liner !command :r !command :r !loo& pattern

4sing Shell Commands to 5rocess n!!command !move command !move fmt +riting :w :w file :w>> file ata

execute command on n lines execute command from cursor to move format lines from cursor to move

write data to original file write data to specified file append data to specified file

Changing the File +hile ,diting :e file :e! file A##reviations :a# short long :a# :una short set short as an abbreviation for long display current abbreviations cancel abbreviation short edit the specified file edit the specified file, omit automated check