Precise movement in Vim
Just several months ago I was a big time Sublime Text user. I was proud of the fact that my editor is lightweight, fast, and easy to use. The plugin architecture is awesome, especially combined with the search functionality where I could look up new plugins just by typing a remotely similar word to it’s title or description.
I thought I was as productive as I could ever be. And probably I actually was much more productive than in any IDE or editor I have tried and used during the previous years. But, as I have started to work at a new company I was proven wrong. Really wrong.
On my first work day, right after I have showed my handcrafting skills in putting together my new desk, the college I share the office room with set up my work environment, and he set up vim as my primary editor and basically forced me to use it.
Now, it wasn’t my first time using Vim. I have used it already to edit things on remote servers and for minor sysadmin things, but have never considered it as a serious editor where I could spend my prime development time. I thought that long beard and a cool nerd looking glasses were a prerequisite to use it.
The first week I have actively used Vim were hellish. All my trusted shortcuts did not work in it, buffers were confusing, and don’t get me even started about yanking things instead of the old and good
In this nightmare I started using my mouse while developing. Selecting text, moving around, and changing buffers, all of it with the help of the mouse… yack. But, that was the only way to stay productive at all in this editor.
After a week or two I learned the terminology and how to customize Vim to my taste. That helped a lot. I have installed
NerdTree, set up some basic shortcuts, and I was ready to go. But, I did not get why am I using this editor. Sublime could do everything Vim could, I could install plugins, I could set up shortcuts, and I don’t even have to do this awkward mode switching all the time.
Movement in Vim is also awkward. Why would I ever wan’t to use HJKL instead of the arrows. One argument everyone told me was to leave my hand on the home row. I still don’t care about that argument. I think it doesn’t give me enough speed improvements to make me relearn my old habits.
The joy of editing
After the initial struggle I started to see some benefits from using Vim. Switching open files was much faster then in my old editor. Plus the tight integration of Vim with the console gave me infinitely more power. Everything now is just a script away.
But the biggest selling point of Vim, and also the moment I fell in love with this editor is when I learned how to move precisely in it. Until then, I always just shuffled around with the arrow keys. That was probably the biggest time waste I always did but never really noticed until I started using Vim.
While using Vim now I feel like I know exactly where I want to go and what I want to do, without any precious time lost on changing my cursors position.
Moving by word forward and backwards with
b. Jumping to the closest character by using
t. Jumping with search. Jumping to matching parens with
%. Changing and replacing words, lines, or bigger segments with only several precise keystrokes. These are the things that I fell in love with, and of course macros. Macros freaking rock!
I still don’t like HJKL movement. It is probably as slow as the arrow keys, and now both I prefer to use neither of them while doing development, and I think that I am at least 2-3 times faster than when I used to work in Sublime Text. That is quiet impressive!