VIM Tip 1: Align

November 19th, 2006 aizatto Posted in Misc, vim | Hits: 50406 | 11 Comments »

I like having my code aligned properly, for example, the following is not cool. The assignment operator is not aligned properly :(.


This is what I want, it adds a certain zen to the code.

LIONS  = 1
BEARS  = 3

Yes you can continually hit the spacebar to align it, but imagine if you have alot of values. That is simply going to waste time, an how about if you add a new variable that stretches the alignment? Definetly not cool.

What you want is the Align plugin. This will cover setting up with the Align plugin with VIM v7. So you'll also need vimball plugin to install it.

Once you've downloaded vimball move it to your vim plugin folder (by default on *nix machines: ~/.vim/plugin)

mv ~/vimballPlugin.vim ~/.vim/plugin

Next open the Align.vba with vim:

vim ~/Align.vba

It will prompt you to enter the following, and just hit enter:

:so %

And there you have it! The Align plugin has been set up.
For basic starters, select a group of text (using Shift V) and enter:

:Align =

VIM will display it as (because its selecting a range):

:'<,'>Align =

Enjoyed that? :3 I did... You can chose to align it with anything, just replace the equality sign with the desired character. For example in Ruby, one might use '=>' for elements in a Hash. Well there you go for starters. The Align plugin has more functionality so do take a peek around.

11 Responses to “VIM Tip 1: Align”

  1. You can also do the following for aligning Rails-like migrations code:
    * select text using visual mode
    * type either:

    For the documentation on this:
    :help alignmap-tsp
    :help alignmap-tsq

  2. Your web site is definately worthy of a bookmark, thank you!

  3. Thanks for the publish. My partner and i have constantly observed that a lot of people are desperate to lose weight because they wish to appear slim in addition to looking attractive. Having said that, they do not often realize that there are more benefits so that you can losing weight additionally. Doctors declare that overweight people are afflicted by a variety of illnesses that can be directly attributed to their particular excess weight. Thankfully that people who are overweight and suffering from several diseases are able to reduce the severity of their illnesses by means of losing weight. It’s possible to see a constant but noted improvement in health if even a bit of a amount of weight reduction is obtained.

  4. ????? ???????????, ???? ?? ???????.

  5. I think that just about everyone around the world is suffering from something. It usually just comes down to money. I quit my job about 11 years ago and have never looked back (I make all my money online). If there is a money making method out there that I have not tried, I would be quite surprised. There are many great reasons why Internet marketing is so much better than punching a time clock. Let me just go ahead and tell you what I am getting at. If you are will to think outside the box, break away from the traditional GURU crap and see a WORKING method that you can implement right away, you need to check this out. It was put together by someone that I highly respect. He really knows what he is doing when it comes to making money online and he is the real deal. This guy is really something else and this new money making method will keep you up at night with excitement. After you watch the videos, you will see why he has made this an invitation only program (don’t worry, I have the invite for you). Using automated software and reverse engineering, you too could soon be raking in the bucks. Get paid $100 to $200 a shot. This method can be used by anyone. You don’t need to have experience in Internet marketing. I can’t give too much away here but it would be a good idea to get in on this earlier rather than waiting. This is a real no-brainer. I really think that this will make a huge difference for you so go take a look at the video. ->

  6. For anybody who is and also will probably vinylacetate breastfeeding your baby while you [i]pancreatitis caused by lisinopril narcotic interaction[/i] colestipol, presiona with all your physician.

  7. good distribute, i definitely really like this site, keep on this

  8. Hi!! Let me start saying that this plug-in is awesome. However I’ve found a strange behaviour when using it along Doxygen comments. As you may know there are several ways of writing this kind of comments:

    /** … */
    /*@ … */
    /*! … */
    /*!< … */
    and so on.

    Let me show you how aligne plug-in alignees them:

    /* * … */
    /* @ … */
    /* ! … */
    /* !< … */
    // /

    This sort of behaviour breaks your code (at least for Doxygen). Is there an option that might prevent this misbehaviour, or perhaps it can be taken into account for future plg-in's releases?

    Thank you and congratulations!!

  9. Pierdolone sex boczniaki kurwa kocham te grzyby nosz ja jebie jeban?
    cipk? chi?sk? kurewki jebane sex, sex i jeszcze raz porno sex
    boczniaki kurwa grzyb pierdolone Google chuj wam w dupie wsadze wam sex boczniaki w dupe.

  10. Excellent post. I certainly appreciate this site.
    Continue the good work!

    website (Adeline)

  11. Very useful! Thank you.

Leave a Reply