I like the idea that programmers should be eclectic:
eclectic [iˈklektik]: adjective deriving ideas, style, or taste from a broad and diverse range of sources: her musical tastes are eclectic.
Playing around with different languages, libraries, and systems can lead to new ideas. One of my favourite programming languages for experimentation has always been Lisp: nobody pays me to use it, but I enjoy it nonetheless.
Some languages or language communities have strict ideas about formatting. One example of this is the Go language -- it comes with the
gofmt program for formatting your source files according to their rules. If you want to experiment with Go, you might find your current settings aren't quite suited to it, particularly if you've got this in your
set tabstop=2 set shiftwidth=2 set expandtab
I think this trend has come from the sheer amount of prominent Ruby developers that share their
.vimrc files on GitHub, and it's definitely easier for new Vim users to use someone else's settings. The thoughtbot dotfiles are a good example of that particular trend.
So what do you do if you're a fellow eclectic programmer, prone to experimenting with languages that don't quite fit the Ruby world view? Fortunately, Vim has a solution for this, and it's covered in the Vim wiki under Keep your vimrc file clean.
The basic principle is to add a
.vim/ftplugin/language.vim file with the settings for a specific programming language. The settings in these files will be loaded after your
.vimrc. Vim has file type detection support, so when you start editing a given file, specific settings can be loaded based on the file type.
set commands into
setlocal. Off the top of my head, I'd say something like this should work for
setlocal ai ts=8 sw=8 noexpandtab
This is much easier than trying to use
autocmd in your main
The next time you're testing out an unfamiliar programming language, remember
setlocal and you should get Vim ready in no time.