I find it surprising on how little time coders spend on their development environment (the “dev env”). And especially, I find it amusing that I can find, refactor and test code way faster than the Netbeans IDE users in my office, with just a shell and Vim setup.
So why is a good dev env necessary? Because we do searching, refactoring, editing and updating of code much more than appending fresh code, and this also applies to code that you wrote half an hour ago, because you will want to quickly refactor it when a new constraint, a new requirement, a new design or a new idea comes to your mind.
I learned this lesson while I was writing my Vim book. Since then, I have been investing quite a bit of time on my vimrc
file, heavily customized to my liking.
To give one very quick example – I like the cursor to always be at the middle of the window (as opposed to at the bottom of the screen when you’re scrolling down), so that I can see the lines of code before and after the current line. To achieve this, you simply set scrolloff=999 and you’re done. A one-line setting, but it makes a world of difference in usage.
Extrapolate this to dozens of customizations and you have just optimized your environment for lesser time at the keyboard, lesser time fighting the editor, and more time on the actual code. You do not want to break your flow of thought because you’re unable to quickly switch between the right files (say, between the controller and the view files), and so on. [1]
These customizations are stored in .vim
and .bashrc
files, collectively referred to as “dotfiles”. I have been asked quite a few times by readers of my book to share my dotfiles, but I was not comfortable to share it because I felt it was too hacked up and did not have a good “base”.
So when I came across bash-it and vim-addon-manager, I knew they were good foundations and a good excuse for me to overhaul my bash and vim setups.
And lo, behold, my dotbash and dotvim repos (on GitHub).
These are my actual working environments at office and on my personal laptop, so if you don’t agree with some of my defaults, fork away.
Now, on to what is interesting about my setup…
bash-it provides great defaults and aliases, right from ..
as a shortcut for cd ..
and ...
for cd ../..
to bash completion setups for git, rake, etc., and of course, a gorgeous theme to use:
The best part though is it’s neat organization into aliases, completion, custom, lib, plugins, themes and template folders. That makes a big difference in the long run, for the same reasons why a cleanly modularized codebase is better than one giant script.
And it will get various new features over time contributed by the community, example, completion of server names for ssh.
vim-addon-manager provides a super-simple way to install plugins into separate folders and then use them all, instead of lumping all of them together into a .vim
folder. Just add the name of a new Vim plugin to the list of plugins you want to load, and it will automatically fetch the plugin and install it for you! This makes it easy to play around with new plugins as well as a simple way of having the latest version of the Vim plugins.
I use vim-addon-manager
, but there are alternatives – others prefer pathogen.vim and there is also Vimana which gives you an apt-get
-like command to search for Vim plugins. Choose your weapon.
There are caveats to vim-addon-manager, mainly that all plugins don’t seamlessly work with it. For example, I couldn’t get pyflakes.vim to work with it, so I had to unzip pyflakes into my regular .vim
directory to use it.