Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically align python variable assignment lines in vim

Tags:

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?

like image 795
Paul D. Eden Avatar asked Dec 10 '08 22:12

Paul D. Eden


1 Answers

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.

like image 157
Bartek Avatar answered Oct 10 '22 23:10

Bartek