Monday, January 16, 2012

What Are Your Options?

Gnnnh! Gack! *curse* *pound-fist* *cry-like-a-baby*

You know the frustration. You know there's an option in Vim for what you're trying to do... You're sure of it. You've used it before! You've seen people talk about it on #vim. You've bored your wife over dinner with it. You just can't remember it now. It had a funny name. It wasn't quite what you'd call it. What was it again?!  Bah!

What do you do now?

You could log on to #vim and ask there, and that's fine - hundreds do.  You could try to google it, but then you've just failed. Most times, trying to find Vim options in google yields more noise than signal.  You could paw through the vim docs yourself, though you've probably already tried that and failed with all of the names you would have called the option. Are they all your options? Are you doomed to a humiliatingly simple response on #vim that, once seen you say, "Bah!  That's it! Gnnnh!"? No. You have other options. In fact, you have :options .

The Options Browser

An almost criminally unknown fact about Vim is that it has this awesome Options Browser built right in to display and modify all of your Vim settings. Jump into vim and type :options to start playing with it. Read all about how to use it in :help :options.

Demonstration

A Vimmer asked on the channel today: How do I blah blah c++ blah label blah blah indent? And I thought, :options! Well, actually, I thought :help 'cino, but then I thought of this cool article to explain the learning moment. Here's how you can find an answer to that sort of question all by yourself:

  1. Open the Options Browser with :options
  2. Search for indent with /indent
  3. Press <enter> to go to that section of the Options Browser
  4. You could just scroll down through the options at this point - at least we're in the right ball-park now... OR Seeing we're interested in C stuff, search for C with /\<c\>

And look! Three C options glaring at us, inviting us to press <enter> on their descriptions to learn more about them. And, indeed, in this case, it's the cinoptions that we're after.

How's that? No more crying over lost options. :-)

No comments:

Post a Comment