At the very least I always uncomment "syntax on" in /etc/vim/vimrc

  • Beware, always having syntax on can be a bad idea if you often edit large files. On larges files (dozens or hundreds of MB), syntax highlighting can cause vim to become unresponsible for several seconds, as it eats a lot of CPU. Just try editing a huge XML file... Of course you can always do :syn off (once vim has recovered...).
    – sleske
    May 28, 2010 at 1:32

10 Answers 10


Our CTO has a pretty feature-filled Vim configuration on GitHub.


  • Syntax highlighting, 2 space tabstop, expanded tabs.
  • NERDtree, a file-tree view similar to TextMate's project drawer.
  • FuzzyFileFinder, plugin to do TextMate's cmd-T functionality.
  • Lots of color themes with a nice one (twilight) default.

I find it great for Ruby coding, as our system administration tools are written in Ruby.

  • I've just played with a bunch of these and there's a lot more to investigate with the vim config you listed but it fits my expectation of sane defaults and useful features. Not sure how a community wiki lets me vote as 'answered' but anyhoo. Thanks!
    – Gareth
    Jul 11, 2009 at 3:44

First, if you have more than a couple machines you work with, consider putting your ~/.vim/, ~/.vimrc and other useful config files (screen, your shell, etc.) in a revision control system. I prefer using darcs - it's cheap on Debian systems (no need to install Haskell compiler, just install the package directly), distributed, and has great interactive modes. If you know/like git, you can also stick with that.

My current config files are available in my darcs repository, http://repo.harnir.net/. Some specific examples from my ~/.vimrc follow. Sorry, no links for scripts, etc. because I'm a new user, but all those you can find on http://vim.org/.

Essential ViM scripts for sysadmins

  • a backup script is a must, when you edit remote files. I use cbackup.vim script, which keeps last 10 copies of each edited file in a central directory and automatically removes old ones - just put in your ~/.vim/plugins/ directory and forget about it :-)

  • TaskList lets you quickly search for FIXME, XXX and TODO tags in current file, display them and go to the tag with just one keypress. If you use these tags, consider installing this one

  • dbext is essential for all DBA, also very useful for programmers working with databases. Let's you run queries, check structure of the databases and whatnot. It is essentially a front end for tools like mysql, sqlite3, sqlplus and others. If you work with databases, it's a must!

Syntax files

I haven't seen many useful syntax in the wild, most files sysadmins work with are configs in /etc and they are usually pretty well highlighted. In my ~/.vim/syntax/ I currently have syntax for CSS colors, which is awesome (also good for web developers), but the rest isn't very well written, I'll perhaps update them in the spare time. Additional syntax files worth having are for: dhcpd.conf, /etc/network/interfaces, nginx configuration files, and SpamAssassin's local.cf.

Useful tip with syntax: if a configuration file isn't recognized (has a weird name, like /etc/apache2/sites-enabled/some.domain.com, you can either append correct extension to it's name (in this case .conf) or add a ViM modeline at the end of it:

# vim:filetype=apache

ViM configuration options

Most of the configuraion options is very popular, like set nocompatible ruler etc. Very good options to have are:

  • set gdefault: inverses the g mode in s///g - with that option /g will be used by default, so you don't need to add it every time - just add it to turn it off

  • set incsearch ignorecase smartcase hlsearch: essential for searching through files - incremental, shows matches in real time, search ignores case unless you use upper case letters

  • set pastetoggle=<F6>: or other key which you prefer, toggles between paste and nopaste modes, a must if you copy-paste something from a web pages like ServerFault :-)

  • set noerrorbells visualbell t_vb=: get rid of the annoying bell or visual bell every time you do something ;)

Functions, keyboard mappings

  • paste your user name and current date into a file, useful if you work in a team and add comments in files about who changed something when. Just write xxsig and press space, it will be changed to something like harnir 20090531. For this to work correctly with root (ie. write your user name instead of root), you need to log in using sudo.

    iabbrev xxsig <Esc>:r ![ -n "$SUDO_USER" ] && echo "$SUDO_USER `date '+\%Y\%m\%d'`" \|\| echo "$USER `date '+\%Y\%m\%d'`"<CR>I<BS><Esc>A
  • Insert comment "lines", like # -- Some title -------------------{{{1, length 78 characters - press \com# in normal mode and there it is. You will be automatically in Replace mode so you can add the title:

    nmap \com# O# <Esc>72A-<Esc>3A{<Esc>A1<Esc><Home>4<Right>R<Space>

You can easily modify it for other comment systems (", //, etc.), or just check my config file.

Ending touch

If you have your configuration files in RCS system, you might want to sometimes include configuration options specific to a certain machine. For that, it's good to have ~/.vimrc.local file, included automatically at the end of the configuration (if it's present, of course).

if filereadable(expand("~/.vimrc.local"))
        source ~/.vimrc.local
  • The last tip - good though it may be - doesn't work when you have NFS-mounted home directories: no matter which machine you are on, your home directory will be the same. Note, too, that that tip depends on the definition of "~" - some shells don't support that shorthand.
    – Mei
    Jun 23, 2009 at 17:10
  • As a sysadmin, you probably work on the servers on 'root' account, which should be local and not mounted via NFS. In this case /root/.vimrc.local should work fine.
    – drybjed
    Jun 24, 2009 at 8:42

Not really sure what part of this is specifically sysadmin related, but my essentials are:

syntax on
set background=dark
set shiftwidth=2
set tabstop=2
if has("autocmd")
  filetype plugin indent on
set showcmd             " Show (partial) command in status line.
set showmatch           " Show matching brackets.
set ignorecase          " Do case insensitive matching
set smartcase           " Do smart case matching
set incsearch           " Incremental search

I also always ensure the machine has access to the nginx syntax highlighting file.

  • I only phrased it like that to separate what might be specifically 'programming' related for a .vimrc Should I change the question do you think?
    – Gareth
    May 7, 2009 at 7:37
  • Nah leave it as it is, I'm sure some people with have sysadmin related stuff, just not me. May 7, 2009 at 7:42
  • Generally agree with this... But a tab is 8-spaces. Anything else and it behaves differently in vim then in less/tail/cat. Might be one of those religious things though. Jun 4, 2009 at 21:32

If you are usually working at a user, than this make it possible to "pipe" a file to sudo so it can be saved.

cmap w!! %!sudo tee > /dev/null %

use the command:


to envoke sudo and save the file.

  • Interesting. Why do you use tee instead of cat ? May 7, 2009 at 7:22
  • 1
    Because cat won't write anything to a file; it just writes to stdout. May 7, 2009 at 20:38
  • cat - > % Works just as good.
    – olle
    May 31, 2009 at 9:49

You can also look at this SO question: What's in your vimrc?


Shameless plug. This is not really a .vimrc change but rather a VIM plugin. I use RCSVers on every installed version of VIM. Basically it uses the RCS command to save off a version of any file you edit. You don't know how many times I've screwed up a config file only to have RCSVers save me by showing me the changes I've made.



Don't use .vimrc to avoid learning VIM

Since I know that a lot of VIM new comers will read this, the best suggestion I have is: "Do not get lazy and put map entries in your .vimrc" Learning non-standard ways of doing things in VIM will make you feel like a total gimp when you are without your vimrc. The learning curve for vi is steep, but you are not doing yourself any favors by choosing not to learn.

  • 1
    Vim has nice features. Why not use it ?? When you have to switch to vi, it's temporary. If you think you'll have to work heavily where vim is not installed, it's worth to install it.
    – Luc M
    Aug 8, 2009 at 16:08

At least a portion of my answer is the same as my programming .vimrc:

set hidden
map <TAB> :e#<CR>

map <F7> :set paste!<CR>
map <F8> :set hlsearch!<CR>
map <F9> :!co -l %<CR>:e<CR>
map <F10> :!rcsdiff %<CR>
map <F11> :!ci -u %<CR>:e<CR>

If at least some files that you're editing aren't in RCS, they should be! :)


Disabling all the "smart" indentation modes. Great for programming, hell for config file.


I often end up using strace to track down odd issues. As a result, trying to syntax highlight some of the lines can get ridiculous with a large string string. This being the case, I use set synmaxcol=2048 to limit the syntax highlighting to 2048 columns.

I'm also quite a fan of the taglist plugin which uses exuberant tags. So far I've been able to push around the compiled ctags binary around and haven't come across any library issues. This quickly allows me to navigate among any of the code I work with. Those generally being Perl, Python, or C.

Not the answer you're looking for? Browse other questions tagged or ask your own question.