To get all of Vim's useful features (and replace the horrible default
- Edit your ".vimrc" file.
$ vim .vimrc
- Now you're in Vim in command mode. Execute the following commands:
- Fix the backspace and arrow keys in insert mode
- Enable syntax highlighting
- Enable automatic indentation
To set the tab width to 2 or 4 characters (the default is 8 characters,
which is too big), add the following commands to the bottom of your .vimrc
" Indentation settings
To make Vim insert spaces ("soft tabstops") instead of real tabs ("hard
tabstops"), add the following:
" use soft tabstops
Which should you do? Honestly, it's a personal preference. You can change
the width of real tabs by changing your editor's settings, while spaces mean
that anyone can view your file as intended without changing any settings.
IMPORTANT: makefiles require real tabs. If you choose to use spaces for
your code, you will need to temporarily change your settings when you edit
a make file. Use the following commands while in Vim:
Or, you can just use another editor, like Nano (which also defaults to
real tabs) when editing makefiles.
Last updated 12/17/12