DCL Labs     Files     Network Status     Other Links     About DCL     Home     Search    
Display Your IP     Browser:   CCBot/2.0 (https://commoncrawl.org/faq/)

'vim' or 'vi' commands.
A list of some of the more popular 'vim' commands and settings. This is a very awkward editor to first learn to use, but extremely fast and powerful. Vim can open extremely large files and one of the first primary editors used in the Unix environment. The main difference between the standard vi editor and vim is, you won't be able to do things with block commands like block column editing.
Additional information can be found at http://vimdoc.sourceforge.net/htmldoc/.

Key Value
vim filename Open an existing filename with vim.
vim -o file1 file2 ... Open two or more files with vim in split screen mode on top of each other. Each file opened has it's own editing area. Note ':qall' to quit, OR ':qall!' to lose changes and quit all files. You can close the immediate window you're in by using ':q'.
vim -O file1 file2 ... Open two or more files with vim in split screen mode side by side. See next command.

ESC50iRepeat this. ESC Repeat phrase 50 times. Hit the Esc key, type 50, then i for insert, type or paste in phrase you want, then hit ESC
CTRL-ww Switch to the next split window when starting up multiple files. (vi -o file1 file2 ...)
CTRL-v CTRL-M This is how you enter the control code ^M, in to the vim editor.
SHIFT-g Takes you to the very bottom of the file.
:1 Takes you to the very top of the file.
:5 Takes you to the fith line of the file.
0 (Zero) Takes you to the beginning of a line.
$ Takes you to the end of a line.
d$ Delete from cursor to the end of that line.
w Move right by one word.
b Move left by one word.
CTRL-SHFT-f Toggles between default window size and full screen window.
CTRL-f Page down.
CTRL-b Page up.
o Insert a new line in the file.
:[number] Takes you to that line number. Example ':5' takes you to line 5.
:%!cat -n
:%!cat -b
Add permanent line numbers inside a file.   Line numbers can be kept when written out.
Same,  but empty lines not counted.
:set nu
:set nu!
Show line numbers in file.
Don't show line numbers in file.
Marking and editing column blocks. Steps for editing column blocks.
  1. CTRL-SHFT-v (Debian CTRL-v) to mark column block x to cut CTRL-P to paste back in. OR
  2. To insert in to a column block, first move to the area you want to insert the block at. Then hit CTRL-SHIFT-v which can mark the block by moving arrow key down that column. Then hit SHIFT-i, type anything you want to insert and then hit ESC, which adds that new information.
copy block column
  1. First, move cursor to start of block column to copy.
  2. Hit CTRL-SHFT-v (Debian CTRL-v) to mark starting of block column.
  3. Move cursor down to desired location of block.
  4. SHIFT-y to yank
  5. SHIFT-p to (paste) block.
sorting block column
  1. First, move cursor to start of block column to sort.
  2. Hit CTRL-SHFT-v (Debian CTRL-v) to mark starting of block column.
  3. Move cursor down to desired location of block, allow a few characters in column.
  4. :sort OR :sort! for reverse order.
  5. For futher sort info, search for 'vim sort column'
example ;
vim character recording steps. Record a sequence of characters for play back..
  1. hit 'q' [0-9] ex> q1
  2. Do all your editing, hit ESC and then 'q' again. This will stop recording.
    • Or, you could hit 'ESC @1q @1' for continuous repeat until the entire column is complete.
  3. To play back what you've recorded use the '@' symbol, @[0-9] ex> '@1'.
  4. There are quite a few buffers you can use to record with.
CTRL-v Visual select block mode
  • once you have rectangular block, you can remove block with 'd'
  • insert text in front of the block with capital 'I'
  • append text after the block with capital 'A'
  • change text with 'c'
  • cut text using 'x' and paste using 'p'
  • change text to single characters using 'R'
gq Word wrap - make text, comments look nicer
v Visual select mode
 :bd Close buffer
 :ls List buffers
 :b1 - :bn Switch to buffer n - :b5 - switch to buffer 5
 :sbn Same as :b1 - :bn, but split
 :CTRL-w q Close current buffer/window
 :on Show only current buffer
 :mkvimrc file Save VIM settings
 :new file Open file in new window
 :split Split current window
set wildmode=longest Tab clompletion behaves more like in emacs or zsh. To get the full list, press CTRL-D
set hlsearch Hilight the search results
set incsearch Incrementally search (like emacs)
set guioptions-=T Remove toolbar
set guioptions-=m Remove menu
set guioptions+=f When running gvim, it will stay in foreground.
set autochdir Automatically cd to directory of the buffer. This is a great feature, but it only seems to work on certain VIM clients even though it is in the help file.
colorscheme darkblue Select "darkblue" as color scheme
set selection=exclusive Only select up to (not including) the character where cursor is
CTRL-^ Switch buffer
CTRL-w CTRL-^ Split and switch
set path=/some/path/** Set internal find path to /some/path and all subdirectories
 :find file Search for file in the path
set smartcase Search with regards to case like in emacs (type small case will search case independent, type mixed case will search exact case) - Has to be used with :set ignorecase
CTRL-a Increment number right of the cursor
CTRL-x Decrement number right of the cursor
CTRL-] Jump to label
CTRL-T Go back
] CTRL-i Jump to file under cursor
% Jump to matching {}, (), [], ...
 :make Compile project
 :make -C directorye Compile project in specific directory (Only gmake)
 :cc Show current error (after :make)
 :cn Go to next error (after :make)
 :cp Go to previous error (after :make)
* Search for word under the cursor
[ SHIFT-i Display all occurances of the word under the cursor in the file