Sunday, March 6, 2011

How to automatically align python variable assignment lines in vim

I would like to automatically align lines of python variable assignments in vim.

For example I would like to change this:

a = 1
banana = 2

into this

a      = 1
banana = 2

automatically in vim.

Is there a way to do this?

From stackoverflow
  • The Align plugin does this and much more.

  • Try the align plugin.

    It's described here...

  • You are probably looking for the Align plugin for vim:

    http://www.vim.org/scripts/script.php?script_id=294

    Once installed, you simply select the text you want to align (Shift V) and type:

    :Align =

    This will align the text based on the = character, so you can use anything you want really.

    Hope that helps!

  • Just note that this goes against style guidelines ;)

0 comments:

Post a Comment