I <3 vim !

I’ve been a vim user for a long time. I’ve always liked vim, because the modal interface fits my brain and the keybindings, my wrists (which never really liked emacs).

Now, although I have used vim for a long time, I often tend to use a small subset of the power that this awesome editor offers.

I would like to say that this is because “what I know, is all that I need to know”, but the simple truth is it’s because I am too lazy to read the docs.

That said, I *do* sometimes feel the urge to become more productive, which leads me to invest time into really understanding my basic tools (vim, firefox, thunderbird, pidgin, windowmaker, aterm/xterm/rxvt).

Today, I decided it was going to be vim. Here’s what I learned:

  • Since version 7.0, vim has a builtin spell checker (“:help spell”; I was using the vimspell plugin all this while).
  • The ‘-x’ option [1] ! Look it up !
  • vimgrep (“:help vimgrep”)

Since I was so impressed with what I learned today, I’m listing down some of the things that I do know about. Some of these, you might already know, and if you don’t, I think you should.

Note that I’m not explaining any of these. This is more like a quick-n-dirty, see-and-do, reference. So, I’d suggest open up a decently large text file (something with more lines than your window size) and try out what’s listed. If you like what you see, the vim doc is beautiful, just pull out the help topic mentioned to learn more.

Note also that most of these refer to ‘command’ mode, ie: You need to press ‘Esc’ before trying any of these out.

  • visual mode (“:help visual”) – Not spectacular, if you already know about it. If you don’t, do a ‘v’ and move around the text, yank-n-paste, you’ll get the idea.
  • visual-block (“:help visual-block) – Now, this one, I’ve seen a lot of ‘old’ unix guys didn’t know about (which is a bit strange). Anyways, do a ‘Ctrl-v’ and move a couple of characters left/right and then up/down, yank-n-paste, you’ll get the idea …..neat huh ??
  • folding (“:help fold”). In visual mode, select a few lines, do a ‘zf’. To open, do a ‘space’ or ‘zo’ on the fold.
  • Editing an entire block – Using a visual-block, select a set of lines. Now, without pressing Esc, try some editing commands, like type in ‘I’ followed by #. Now, press Esc.
  • Inserting special characters in your search-and-replace patterns: An example is best for this one. Do this:

    Create a file with the contents:
    <HTML><HEAD><TITLE>42</TITLE></HEAD><BODY>The answer is</BODY></HTML>
    Do a ":1,$ s/></>Ctrl-v+Enter</g"

    See what I mean ?

There is so much more, but now I am bored …and I think at least for those who have not invested time in learning vim by reading the docs, at least some of this stuff would be new.

Maybe, I’ll post about vim again later. Till then though, here’s something that you could possibly use — My vim files. Just untar, rename the contents correctly (ie: mv {dot_,.}virc && mv {dot_,.}vim) and copy them to you $HOME. The .vimrc is written from scratch and mostly well commented.

Thanks for reading.

[1] wtf !! …and I’ve been breaking my head over getting an nice, easy to use and small tool for storing sensitive stuff (like account numbers, login/passwords, etc) and was left unsatisfied with all the fancy GUI tools and the CLI one’s I’d have to install separately on each new system)

UPDATE: The default encryption algorithm used for the -x option is breakable. It is the same as that which Pkzip uses (and has documented). So, -x is probably not a good idea for ultra sensitive stuff, but good enough and convenient enough for short lived files which don’t need high level of security. For proper encryption support in vim, I would recommend using Noah Spurrier’s OpenSSL vim plugin. . (Now included in the vim files link above).

  1. awesome!!

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>