Some .vimrc settings

2012-Jun-03, Sunday 11:34 am
You know that feeling when you get into a new machine and vim is just configured wrong? Here's a couple of the configuration options I find most useful. Simply in your $HOME folder edit (or create if it doesn't exist) .vimrc.

set tabstop=3
set shiftwidth=3
set expandtab

This bunch basically swaps tab with a specified number of spaces, here 3. This is mostly useful if you're going to playing with shared code. Indentation can vary between people and platforms, so boiling it down to 3 or 4 spaces will be most portable. But instead of having to press space 3 or 4 times this lets you just press tab once, and vim will make the necessary changes.

set autoindent

This again is helpful when coding. Means that when you press Return onto a new line you will be at the same indentation level as the line above, like most IDEs. But, word of warning, if you're copy-pasting multiple lines this will go terribly wrong.

set backupdir=./.backup,.,/tmp

All those temp files that automatically get created when you're editing a file never seem to get deleted. And the clutter annoys me. This tells vim where to put the backups. First, if I've created a folder called .backup in the current folder use that. If not, use the current path (normal behaviour). Finally, throw them in /tmp; I don't like this option because it means having to keep the names of all the files I edit in vim unique across the machine.

if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

This now, I find really helpful. It turns on syntax highlighting. And search highlighting. It gives you colours. Love it.
In vim the command :TOhtml creates a syntax highlighted html version of your file. Open the html, and copy paste into OpenOffice, and you have lovely syntax highlighted code that is much easier to read.

Profile

chebe: (Default)
chebe

Syndicate

RSS Atom

July 2025

M T W T F S S
 1 23456
78 910111213
14151617181920
21222324252627
28293031   

Expand Cut Tags

No cut tags

Style Credit