Today I read an article on reddit about vi and vim, and it got me thinking. This editor is almost as old as mankind itself, paintings of the vi UI were found in caves along with the cryptic writing “:wq”. People have been using it for as long as anyone can remember. Wars have been waged for it (mostly with the church of Emacs, what with the crusades and all). One of the most influential editors of all time, and I don’t know how to use it. This is unacceptable.

I tried to use it once, but the man page wasn’t very helpful. I had managed to move the cursor, but when I tried to type, everything got messed up. “A plague on your house!”, I exclaimed at the screen, and spent the next fifty minutes trying to exit this infernal abomination. I ended up just pressing the reset button, thus ending my computer’s longest uptime session in quite a while.

This time, though, I am determined to learn how to use this thing. I will try to see if it really is “faster than thought”. This is my story.

Day One

By the way, the days aren’t real days, I am just saying that so I don’t bother you with dates. Anyway, day one. Today I found a nice tutorial on vi and downloaded gVim. Okay, apparently there are commands for moving the cursor and commands for typing. I wonder how much faster this can make me, since I generally spend more time typing than moving the cursor, but off I go.

I am quite fast at using my normal graphical editors, and I am really curious to see if vi can make me any faster. It takes me quite a while to edit now, since I have to spend a few seconds looking back and forth from the tutorial for the keystrokes that do what I want. I also spend some time trying to figure out which key I should press after “d” or “v” to do what I want. I still have no idea which is up, “j” or “k”.

Day Two

I am starting to like it, even though copying and pasting is still a bit frustrating with all the moving around. I haven’t found a way to select something and delete it to paste something else (when I delete it copies the deleted text to the clipboard). I spend less time looking at the command keys, but I still spend time trying to remember them. Also, “j” is down, but I still make mistakes sometimes.

I like the syntax coloring, and I made some configuration changes so now my Python indents are a perfect 4 spaces, and tabs are converted automatically. There is no real tab completion, but it’s an editor, not an IDE, so that would really not be possible. There is completion that completes from all the words in the file, which is better than nothing. I am satisfied.

Day Three

It dawns on me that I don’t have to delete something to paste over it, I just paste while it is selected and it gets deleted. Duh. I am getting faster at moving around, but I still think the “traditional” way with Home/End and PgUp/PgDn is faster (or I’m faster at it, anyway).

I particularly enjoy the “o” command, and I particularly hate the fact that pressing a key by mistake in command mode subtly changes text somewhere without you having any idea, other than thinking “wait, did I just press something?” I guess they don’t call it “mess everything up mode” for nothing. I also like the bewildered looks on people who look at it, and even more on those who try to use it. I am not worried, since there is no way in hell they are going to type “:w” by mistake. Hell, it took me an hour to find out how to quit with “:q”. I still have to look to find the “$” and “^” keys.

I like the built-in sed-like replace thing, even though it took me ten minutes to figure out that I need to prefix it with % for it to replace in the entire file. Who the hell needs “replace on current line” by default anyway? If I only want to replace something on the current line, I’m not going to type it into search/replace, I’m just going to go there, delete it, and type the new thing. Silliness.

Day Four

Nothing eventful, I am still editing stuff. I like the fact that you can move and delete with precision as many words/lines/whatever you want. Now if I could actually calculate how many words/lines/whatever I want to delete with accuracy instead of doing three deletes, two undos and then another two deletes, it would be great.

I also find that I have to concentrate more on the actual editing than on what I am editing, which introduced oversights like mismatched parentheses and the like in my code. I hope this goes away when all the commands become instinctive.

Day Five

I got frustrated while editing with gVim and switched to Komodo. Copy/pasting is a drag, it takes me quite a few tries to get used to it. I feel that it is really distracting me from coding. This is not good.

Long after what should have been day six

I use Linux more and more over SSH at work and I must say, over low latency connections there’s nothing better than vi. See what you want to do, press the appropriate keystrokes, and a bit later, it’s done. I will continue using it in this way for a bit.

Day Seven

I have been using vim for coding in SSH and it has many very handy functions, some personal favorites including d% (delete up to matching parentheses), dt/whatever (delete up to text “whatever”), etc.

Day Eight

I am really liking it. I am equally proficient in normal style editors and vim. I still feel a bit odd using it because I think I can move between lines in windows more easily, although now that I think about it I don’t see how that can be (I use ctrl+left/right which is vim’s w/b and up down, which, well, also exists in vim). I have set gVim as one of my primary editors and use it more and more.

Day Nine

Well, I figured out why I was moving around faster in Windows, and that’s the scroll wheel. Since gVim handles it equally well, I am using it for all my editing (I still use Eclipse for large projects). From creating a textfile to editing code, I use (g)Vim and I’m a good deal faster with it than with normal editors. I still haven’t discovered more than 40% of its capabilities, though (yesterday I stumbled on increment/decrement number, that’s very handy). The “go to matching parenthesis/brace” is ace.

Conclusion

Well, I never thought I’d see this day, but after many frustrations I am now using vim almost exclusively (including right now for this text). It is a good deal more powerful than other editors (regex replacing one command away, tab completion/indentation, etc etc). I don’t like the fact that after leaving insert mode the cursor goes back one character (as well as the fact that you can’t move past the end of line so you can backspace), but I guess that’s something you learn to live with. Also, while in insert mode there’s no ctrl+backspace if you make a mistake so you can delete the word and keep typing. Maybe I can set this up with a macro…\ Overall, vi/m is a great editor and I would recommend it to everyone. The investment is really worth it, and in the end you’ll be better off (plus you don’t lose your windows editor skills, so you’ll be equally proficient in both). An added perk is that you will finally have an opinion in the age-old “emacs vs vi” argument (albeit a one-sided one). In conclusion, vi rules.:wq