.vimrc Tweaks

I’ve recently made the plunge and standardized all my text editing needs around vim. That is to say vim when in local or remote terminal sessions and macvim when editing local files.

http://twitter.com/#!/stephdau/status/51275806772707329

Since this has lead me to tweak my .vimrc file, I figured I’d post its current incarnation for posterity.

[sourcecode]
set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab
set nowrap
set ruler
syntax on
filetype indent on
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType c set omnifunc=ccomplete#Complete
[/sourcecode]

Here’s what it means:

  • tabs config: I like my tabs to be real tabs, but show as 4 columns/spaces wide, not 8
  • nowrap: most of my edits involve code and I don’t like soft text wrapping in that context. I just use set wrap when I need it instead
  • ruler: displays the current cursor’s position (line/col) at the bottom right, which means I don’t need line numbers displayed and save some screen real-estate
  • syntax: I like pretty colors when editing code 🙂
  • filetype indent: cursor remains at the same tab stop when editing indented code and going to a new line.
  • autocmd: sets code completion (AKA: Omni Completion) via ctrl-xo for PHP, Javascript, HTML, CSS, XML, Python and C

Those are the only configs I’ve found myself needing at the moment, but they made a huge difference in my daily productivity. Maybe they will for you too.

Comments

3 responses to “.vimrc Tweaks”

  1. Stephane Daury Avatar

    I’ve also set both my macvim and terminal font to Monaco 10pt (non anti-aliased), which is my favorite for text editing on the mac.

  2. Xopher Avatar

    Instead of ruler, you can also type ctrl-g to get line number and file size.

Leave a Reply to Xopher Cancel reply

Your email address will not be published. Required fields are marked *