This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
useful_vim_commands [2008/07/30 18:48] Joel Dare |
useful_vim_commands [2020/06/01 22:53] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Useful VIM Commands ====== | ||
| + | |||
| + | The following are commands I find useful when editing in VIM. To make a particular command permanent, add it to your .vimrc file. | ||
| + | |||
| + | ===== Auto Indenting ===== | ||
| + | |||
| + | To use the indent from the previous line. | ||
| + | |||
| + | :set autoindent | ||
| + | |||
| + | ===== Syntax Highlighting ===== | ||
| + | |||
| + | Turn on syntax highlighting. | ||
| + | |||
| + | :syn on | ||
| + | |||
| + | ===== Make ===== | ||
| + | |||
| + | Set the make program for PHP development. | ||
| + | |||
| + | :set makeprg=php\ -l\ % | ||
| + | :set errorformat=%m\ in\ %f\ on\ line\ %l | ||
| + | |||
| + | Now, \\:make\\ will execute and show any errors. | ||
| + | |||
| + | |||
| + | ===== Tab Stops ===== | ||
| + | |||
| + | To set your tab stop size to 4. | ||
| + | |||
| + | :set tabstop=4 | ||
| + | |||
| + | To set the indent width (not sure how this differs from tabstop described above). | ||
| + | |||
| + | :set shiftwidth=4 | ||
| + | |||
| + | To insert spaces instead of tab characters when you hit tab you can: | ||
| + | |||
| + | :set expandtab | ||
| + | |||
| + | To change all existing tabs to spaces, use the following. | ||
| + | |||
| + | :retab | ||
| + | |||
| + | ===== Tabbed Windows ===== | ||
| + | |||
| + | To edit in a new tab. | ||
| + | |||
| + | :tabe | ||
| + | |||
| + | Then, to switch to the next/previous tab use //gt// or //gT//. | ||
| + | |||
| + | ===== Code Completion ===== | ||
| + | |||
| + | To complete the current word, press CTRL-X, CTRL-O. | ||