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

  1. Ubuntu Tutorials | December 24, 2006 at 1:29 pm | Permalink

    It seems we've all got Vim on the mind. I did a post about the same time herlo did, I've got a second posted today and now you.

    I think between the three of us everyone should be a Vim pro by the end of the day! Good post.

  2. G Thornock | December 25, 2006 at 11:24 pm | Permalink

    You mention column mode editing as a feature of Cream. I assume by this that you haven't used column mode editing in vim (without Cream). It's available, though. Generally you can do column mode editing with ctrl-V. Of course, this breaks if you're using "behave mswin" or some other key remapping that makes ctrl-V act as a "paste" key, but if you do that, hopefully you've also remapped something else to do column mode.

{ 1 } Trackback

  1. [...] Also, for some more advanced uses of Vim including using it as a file explorer, using tabs and quite a bit more check out my buddy Aaron’s post Use Vim! Like this post? Share it!These icons link to social bookmarking sites where readers can share and discover new web pages. [...]

Post a Comment

Your email is never published nor shared.