Image of the glider from the Game of Life by John Conway
Skip to content

Use Vim

With all the Perl programming that I have been doing lately, I need a good editor. GEdit, KWrite and company are OK, but I need something with a bit more umph. The Perl plugin for Eclipse is very nice, but Eclipse is a bit much for what I'm doing with Perl, which is just simple scripts.

Enter vim 7.

I've always been a fan of vi and it's various incarnations, particularly vim (nvi and elvis are nice, but vim takes the cake). The problem is learning all the funky commands to navigate around it. I don't mind learning them, I just lack the motivation to do so. So, I end up using GEdit or some other GUI editor. However, today, I learned a number of commands that are making my outlook on vim easier.


How did I not know about this command before? Turning vim into a file explorer?? Rock on!! Thanks to Black_Chaos for this tip!

:cd /path/to/file/directory/

Extending the ability to browse to any directory with :Explore, you can change directories in vim itself, and open a file from there. Thanks herlo!

:tab{new, close, next, previous, etc.}

For those who are now caught with your pants down, vim 7 supports tabs! This is really great news, as I usually have more than one file open at a time. Word to dataw0lf.

:<up_arrow> and :<tab>

The thing that separates the boys from the men is the ability to take advantage of your history and tab completion in bash. The same goes for vim. <up_arrow> will allow you to browse through your history and <tab> will auto-complete vim commands.

This is pretty cool stuff. And it only gets better from here. Using search and replace, regex, cut/copy/paste, undo, and many more are available. These are just a few of the commands that I have stumbled upon while playing around with vim today.

One last thing about vim, however, that I need to cover. Text- or console-based applications don't appeal to everyone, and vim's learning curve can be very intimidating. So, there are some developers that have created graphical front ends to vim, to make the learning curve less painful. GVim is no doubt the most popular, but I have a better application: Cream.

Cream has the ability to be used in vi, vim or natively as Cream itself. When running as Cream, the default behavior, all the "standard" keyboard shortcuts are used on the file. Save (^s), cut (^x), copy (^c), paste (^v), etc. However, you can use Cream in vim mode, and act as though you were sitting in the terminal using it directly. The greatest advantage that Cream offers over GVim, in my opinion, is column editing. I can't begin to tell you how nice it is to type the same thing on every row simultaneously. Especially helpful when programming.

Anyway, that's it about vim for the time being. I'm sure I'll come across more cool commands as the days wear on. I'd just thought that I would share these.

{ 2 } Comments