Format text as blocks (second column alignment)

Many times, I have a list of initializers in some of my code, for example:

class Foo(object):
    def __init__(self, data):
        self.foo       = data.getFoo()
        self.bar       = data.getBar()
        self.something = data.getSomething()

As you can see, I like my code similar to a table. In many cases, the above code can be generated using the Vim script coming from the output of some other program ( DESCRIBE "foo";in the database, for example). Unfortunately, the output script usually looks like this: first:

class Foo(object):
    def __init__(self, data):
        self.foo = data.getFoo()
        self.bar = data.getBar()
        self.something = data.getSomething()

So, after the automatic generation of assignment operators, I have to manually align all the instructions for the desired appearance.

Now: is there a way to get vim to automatically align these two halves of statements?

+3
source share
3 answers

. ( ) .

: , Drew video, , .

, :Tab /=, . , , :5,10Tab /= (v v), , : Tabularize, : :'<,'>Tab /=.

Tab - , , . .

: D

+3

Tabular Align plugin.

+1

, :

:s/=/                         =/

, (Ctrl-V), = , . Yank (y), .

, , (10< ), . , .

, .

0
source

All Articles