Jun 2, 2008

vi

I actually started to learn how to use vi after reading this article which explains why people use it - I found it by Googling "why use vi?" if you're wondering.

I'm using the graphical GVim one (or whatever it is called) for reference, apparently different versions do things differently.

It's actually not that bad, once you get over the first few bumps. You have to know about command-mode vs. insert mode, and how to go between them (i to go from command mode to insert mode - this isn't the only way but it is the simplest, Esc to go from insert mode to command mode). You also need to know the important commands :w and :q. Other than that, you don't really need a whole lot. Learning more commands though, is the main reason for using vi. They're actually quite handy.
Currently I still only have used a few, but they're handy. Typing dd (note that all these commands are done while in command mode) deletes a line - this is better than having to select the line and delete it, or going Home, Shift+End, Backspace, Backspace. o inserts a new line and puts you into insert mode onto the new line so you can just start typing. cc clears the line you have selected and puts you to insert mode, cw clears the word you have the cursor on and puts you in insert mode right there. These are all just little tiny things that all add up to make editing code that much easier.

The other thing that is very handy is that vi has been around for a long time. I mean, it predates Windows 95. It came before there was Google (believe it or not, there was a time like this). And in that time, I don't think it has changed much. Anything you need to figure out how to do - at least all the basic stuff I wanted to do - you just Google for it and the answer is right there. Want to turn on syntax highlighting? Google for "vi syntax highlighting" and you will have it. It's very easy to find information on it.

So yeah, there is a learning hump. However, I think that if you actually sit down and learn the basic commands to edit things, then you'll be set. Most people seem to just open it and expect that it works like every other text editor out there. Unfortunately this approach will fail horribly, and then you'll be left with the impression that vi is unusable. I'd say this is wrong, but it is a bit tricky and unintuitive at first. You have to actually sit down with a tutorial and learn it. However, I'm starting to think that for a young programmer who will probably be coding for the next few decades, it is a worthwhile investment to make.

No comments: