<<
Home , Vi

vi editor commands delete (and place in buffer) special x delete current character :r foo read foo into this file after cursor 3 modes of vi 10x delete 10 characters :!command execute the specified command delete current line and return to vi command mode 6dd delete 6 lines :r !command execute the specified unix command you can navigate the file and use the commands on d0 delete to beginning of line and read the results into this file after this sheet d$ delete to end of line the cursor dw delete word :10,20d delete lines 10-20 insert mode 3dw delete 3 words :1,$s/alpha/beta/g from the first line to the last line, change all occurrences of alpha you insert text into the file and can move around copy (and place in buffer) (using the arrows) in the file if you are using . to beta. yy yank (copy) You insert mode by pressing the . :5,10> indent lines 5 through 10 5yy yank 5 lines :20,30< de-indent lines 10 through 20 special command mode pasting Allows you to enter special commands. While in p lower-case pee pastes after cursor miscellaneous editing commands command mode, press : P upper-case pee pastes before cursor u undo . repeat last command using other buffers enter insert mode commands J two lines "a7dw delete 7 words and place in buffer a 5>> indent 5 lines 1 tab i insert before cursor "b5dd delete 5 lines and place in buffer b 2<< de-indent 2 lines 1 tab o lower-case oh opens a new line (below) "ap paste contents of buffer a >% with cursor on a brace, indent bracketed block O upper-case oh opens a new line (above) "bp paste contents of buffer b of lines a append (insert after cursor) <% de-indent bracketed block of lines A append end of line navigation ↑ move up one line saving, exiting 5↑ move up 5 lines .vimrc file : contents to disk ↓ move down 1 line :set ai sw=4 :wq write contents and quit 6↓ move down 6 lines :set number ZZ write contents and quit 1G go to line 1 :q quit 15G go to line 15 :set expandtab :q! quit and don’t save changes G go to last line :set softtabstop=4 H go to of screen (high) :set smartindent searching L go to bottom of screen (low) /foo search forward for “foo” w go to next word ?foo search backwards for “foo” 7w move over 7 words n repeat last search b back one word 0 go to beginning of line $ go to end of line