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.

comments powered by Disqus
useful_vim_commands.txt · Last modified: 2020/06/01 22:53 (external edit)