Some .vimrc settings

2012-Jun-03, Sunday 11:34 am
chebe: (Pi)
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.
chebe: (Default)
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.
Page generated 2017-Aug-20, Sunday 11:02 pm
Powered by Dreamwidth Studios