I’m Salvatore Sanfilippo and I use Vim to write code, those days mostly C code and mostly in order to develop Redis. My background is as Unix system programming and system administrator. Vim was my first serious editor. I started using it when I was 18, now I’m almost 39 and I’m still using it. I spend the majority of my (productive) work hours in a vim window, usually writing C code or Tcl tests for Redis or Disque, trying to get things to work by compiling and testing the changes, and then returning back into vim. My workflow is completely terminal based from this point of view, I don’t use IDEs or other graphical interfaces for development.
Outside Redis (and Disque) development, I use vim to also write Ruby code and shell scripts.
I use OS X TextEdit with a large font to write blog posts and in general to write prose. I’m basically a heavy vim user only for coding tasks, but otherwise a prefer just a big white background simple editor that resembles a piece of paper.
The reason I use vim for editing code is that I find modal editing very comfortable to navigate the source code and make changes. I love macros, visual mode and buffers, and all the fundamental vim functions that make vim so effective when writing code.
Currently I’m using vim 7.3, but given I don’t use plugins or crazy features, almost any version will do for me. And that’s another reason why I love vim: I can have it everywhere.
My vim configuration file is really pretty basic. It claims to be copyright (C) 2001, but actually I made a few changes in the years later.
The fundamental options I use are the following:
set softtabstop=4 set shiftwidth=4 set expandtab set incsearch set ignorecase set smartcase set ruler set showmode set viminfo=%,'50,\"100,:100,n~/.viminfo set autoindent set backspace=2
I set the width of tabs to 4 spaces everywhere and for me
smartcase is a must when searching for stuff.
I use detection of certain file types by extension, like for example
markdown files if called
I love this:
" When open a new file remember the cursor position of the last editing if has("autocmd") " When editing a file, always jump to the last cursor position autocmd BufReadPost * if line("'\"") | exe "'\"" | endif endif
That is, the ability to save the cursor position across edits.
I hate matchparen, so I’ve always
let loaded_matchparen = 1 " Avoid the loading of match paren plugin
I’ve a few common mappings. Two trivial ones I love are:
vmap q <gv vmap <TAB> >gv
In order to change the indentation of the currently highlighted block of code.
I’ve a very strange map:
map 4 $
For some reason sometimes I tend to press
shift when trying
$ to go end of line… and this was so annoying at some point
that I added that map.
My color scheme is “desert”.
Usually I just google when I need something, but I’m the kind of person that does not look to reach perfection. Good enough is good enough so I rarely alter my configurations since I always feel the time spending micro-optimizing configurations is better used to do actual work.
There are a few things I always need to google since I can’t remember, like how to invert the lines in a file. I would like to learn a bit more vim features in order to remember how to do this step by step. Another thing I would like to learn about is gvim and other GUIs for vim. I see people using those tools but I don’t exactly understand what’s the advantage. Maybe there are enough advantages to justify switching to gvim, I need to find the time to investigate…
That it was possible to highlight trailing spaces when editing C, so I enabled it. It’s useful.
No, there isn’t around here AFAIK and in general I don’t go to programming events: day is for coding, night to have fun :-)
Recently while developing Disque, which was originally forked from the Redis code base, I had to use the editor a lot, in an attempt to unify the two code bases with common names. So I had to use vim, sed and grep together for days in order to perform a refactoring that would allow certain patches to be cherry-picked across the two repositories: Redis and Disque.
Sometimes I would like vim to be more “context aware”, that is, if I
change the name of a local or global variable, or a structure field,
or something like that, to easily find all the occurrences where this
is used. Perhaps it’s possible to do things like that but I just don’t
know. However is one of those things which are so rare that I just
grep and forget for the next N months.