0 évaluation0% ont trouvé ce document utile (0 vote)
13 vues1 page
Vi basic commands Summary of most useful commands. Enter editing mode I insert nete t $efore the cursor" s enter edit mode and su$stitute the current character $y se&eral ones"
Vi basic commands Summary of most useful commands. Enter editing mode I insert nete t $efore the cursor" s enter edit mode and su$stitute the current character $y se&eral ones"
Vi basic commands Summary of most useful commands. Enter editing mode I insert nete t $efore the cursor" s enter edit mode and su$stitute the current character $y se&eral ones"
Copyright 2013-2005, Free Electrons, http!!free-electrons"com" #atest update Fe$ 5, 201% Free to share under the terms of the Creati&e Commons 'ttri$ution-Share'li(e 3"0 license" Sources, translations and updates on our free training materials http!!free-electrons"com!training!intro)uni*)linu* " +han(s to #iu$o Chen" Entering command mode [Esc] E*it editing mode" ,ey$oard (eys no- interpreted as commands" Moving the cursor h .or left arro- (ey/ mo&e the cursor left" l .or right arro- (ey/ mo&e the cursor right" j .or do-n arro- (ey/ mo&e the cursor do-n" k .or up arro- (ey/ mo&e the cursor up" [Ctrl] f mo&e the cursor one page for-ard " [Ctrl] b mo&e the cursor one page bac(-ard" ^ mo&e cursor to the 0rst non--hite character in the current line" $ mo&e the cursor to the end of the current line" G go to the last line in the 0le" nG go to line num$er n. [Ctrl] G display the name of the current 0le and the cursor position in it" Entering editing mode i insert ne- te*t $efore the cursor" a append ne- te*t after the cursor" o start to edit a ne- line after the current one" O start to edit a ne- line $efore the current one" Replacing characters, lines and words r replace the current character .does not enter edit mode/" s enter edit mode and su$stitute the current character $y se&eral ones" cw enter edit mode and change the word after the cursor" C enter edit mode and change the rest of the line after the cursor" Copying and pasting yy copy .yan(/ the current line to the copy!paste $u1er" p paste the copy!paste $u1er after the current line" P Paste the copy!paste $u1er $efore the current line" Deleting characters, words and lines 'll deleted characters, -ords and lines are copied to the copy!paste $u1er" x delete the character at the cursor location" dw delete the current word" D delete the remainder of the line after the cursor" dd delete the current line" Repeating commands . repeat the last insertion, replacement or delete command" Looking for strings /string 0nd the 0rst occurrence of string after the cursor. ?string 0nd the 0rst occurrence of string $efore the cursor" n 0nd the ne*t occurrence in the last search" Replacing strings Can also $e done manually, searching and replacing once, and then using n .ne*t occurrence/ and . .repeat last edit/" n,ps/str1/str2/g $et-een line num$ers n and p, su$stitute all .g glo$al/ occurrences of str1 $y str2" 1,$s/str1/str2/g in the -hole 0le .2 last line/, su$stitute all occurrences of str1 $y str2" Applying a command several times - Eamples 5j mo&e the cursor 5 lines do-n" 30dd delete 30 lines" 4cw change % words from the cursor" 1G go to the 0rst line in the 0le" Misc [Ctrl] l redra- the screen" J join the current line -ith the ne*t one u undo the last action Eiting and saving ZZ sa&e current 0le and e*it &i" :w write .sa&e/ to the current 0le" :w file write .sa&e/ to the file 0le" :q! quit &i -ithout sa&ing changes" !oing further vi has much more 3e*i$ility and many more commands for po-er users4 5t can ma(e you e*tremely producti&e in editing and creating te*t" #earn more $y ta(ing the 6uic( tutorial 7ust type vimtutor"