Easy Align plugin for Vim


Easy Align is a plugin for Vim that makes it super easy to align your code along certain whitespace or characters. Unlike the Tabular plugin, Easy Align is actually easy to use, not requiring you to create and recall esoteric-looking arguments.

Below are a few examples of how I typically use this plugin. For everything below, first visually mark out the lines, press : followed by command given below:

  • To align text based on space characters as delimiter:
    • Align on first delimiter: EasyAlign \
    • Align on second delimiter: EasyAlign 2\
    • Align on all delimiters: EasyAlign *\
  • To align based on equals character as delimiter. For example, a block of assignment statements in C++. I visually block it and use the command: EasyAlign=

  • To align based on comma character as delimiter. For example, a block of function calls in C++ along their multiple comma characters: EasyAlign*,

  • To align a block of function parameters, one on each line: EasyAlign-\

The logic behind these commands is straightforward and is explained in the table of examples on the plugin’s Github page.

Tried with: Vim 7.4 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s