| 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.
|
| 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. |
| :%!cat -n | Add line numbers inside the file. |
|
:[number] |
Takes you to that line number. Example ':5' takes you to line 5. |
:set nu
:set nonum |
Show line numbers in file.
Don't show line numbers in file.
|
|
Marking and editing column blocks.
|
Steps for editing column blocks.
- CTRL-SHFT-v (Debian CTRL-v) to mark column block x to cut CTRL-P to paste back in. OR
- 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
|
- First, move cursor to start of block column to copy.
- Hit CTRL-SHFT-v (Debian CTRL-v) to mark starting of block column.
- Move cursor down to desired location of block.
- SHIFT-y to yank
- SHIFT-p to (paste) block.
|
Alphabetical
sorting block column
|
- First, move cursor to start of block column to sort.
- Hit CTRL-SHFT-v (Debian CTRL-v) to mark starting of block column.
- Move cursor down to desired location of block, allow a few characters in column.
- :sort OR :sort! for reverse order.
- For futher sort info, search for 'vim sort column'
|
q[0-9]
example ;
q1 |
vim character recording steps. Record a sequence of characters for play back..
- hit 'q' [0-9] ex> q1
- 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.
- To play back what you've recorded use the '@' symbol, @[0-9] ex> '@1'.
- 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
|