====== vi tips ====== I'm using vim instead of vi. ===== Scripts ===== Helpful addon scripts to vim These script files should reside in ''~/.vim/plugin'':\\ [john@bender ~]$ mkdir -p .vim/{plugin,doc} [john@bender ~]$ ls .vim/ doc plugin ==== rcs.vim ==== [[http://www.vim.org/scripts/script.php?script_id=1111|rcs.vim project page]] This script allows you to manage rcs files automatically: * if the file is checked in and unlocked, and you try to make an edit, the ''rcs.vim'' script will prompt you to checkout and lock the file * when done editing, when you quit the buffer (type: :qEnter),the ''rcs.vim'' script will prompt you to checkin and unlock the file, and type a comment for your changes ===== Information ===== [[http://www.vim.org/htmldoc/visual.html|vim visual mode explanation]] \\ **Indent Multiple lines:** (([[http://mail.python.org/pipermail/python-list/2001-March/074475.html]])) The << and >> commands are used to for block indenting. The >> indents a line right one tab and << indents a line left one tab. You can indent a whole bunch of lines by giving a number the number before the >> or <<. For example, 10>> will indent ten lines from the current cursor position. ===== Syntax ===== vi/vim syntax ((http://www.ss64.com/bashsyntax/vi.html)) ((http://nostarch.com/frameset.php?startat=mug)) ^ switch to insert/edit mode ^^^ | command | description | verified command? | | i | insert text at cursor | yes | | o | insert new line below cursor | yes | | a | insert text after cursor | yes | | I | Insert text at the beginning of the line | yes | | O | Open line above cursor | yes | | A | Append text at the end of the line | yes | ^ switch to command mode ^^^ | | switch to command mode (stop editing) | yes | ^ cursor movement (command mode) ^^^ | + b | page up 1 screen | yes | | + u | page up 1/2 screen | yes | | + d | page down 1/2 screen | yes | | + f | page down 1 screen | yes | | G | go to last line | yes | | ://n// or //n//G | go to line //n// | yes | | 0 (zero) | go to beginning of line | yes | | $ | go to end of line | yes | | ( ) | scroll by sentence (f/b) | yes | | w b | scroll by word (f/b) | yes | | h j k l | move left, down, up, right | yes | | //n////x// | move //x////n// characters/lines where //x// is (h, j, k, or l) | yes | | Arrow Keys | directional movement | yes | | :set number | show line numbers | yes | | :set nonumber | hide line numbers | yes | ^ Deleting text (command mode) ^^^ | cw | change word at cursor | yes | | dw | delete word at cursor | yes | | r | replace one character | yes | | x | delete text at cursor | yes | | D | delete current to end of line | yes | | dd | delete entire line | yes | | //n//dd | delete //n// lines | yes | | ://m//,//n//d | delete lines //m//-//n// | yes | ^ Editing (command mode) ^^^ | yy | copy line | no | | //n//yy | copy //n// lines | no | | ://m//,//n//t //o// | copy lines //m//-//n//, paste after //o// | no | | P | paste above current line | no | | p | paste below current line | no | | ://m//,//n//m //o// | cut lines //m//-//n//, paste after //o// | no | | J | join previous line | no | | ?//string// | search backward for //string// | yes | | ///string// | search forward for //string// | yes | | :set paste | enable paste mode, which pastes without auto-formatting | yes | | :set nopaste | disable paste mode (re-enable auto-format) | yes | ^ View Modes new for vim version 7.0 (([[http://applications.linux.com/article.pl?sid=07/01/11/2141259&from=rss]])) ^^^ | :tabnew //filename// | open //filename// in a new "tab" | no | {{tag>:linux :linux:tips}}