vipin kumar soni
vipin kumar soni

Reputation: 23

Aligning two columns of text in Vim

I want to align the below code:

Sample Code:

.abc  (abc)
.bcd (dfdfd) 
.xyzdddddd            (xyzdfdd)

After alignment:

.abc        (abc)
.bcd        (dfdfd)
.xyzdddddd  (xyzdfdd) 

How can we align this with Vim?

Upvotes: 2

Views: 169

Answers (2)

Mikef
Mikef

Reputation: 2508

Emacs M-x align-regexp (
Does exactly what you are asking for.

Searched 'vim equivalent of emacs align regexp' and the answer is that there is a plugin called
'easy align'
See
www.reddit.com/r/emacs/comments/59uh2m/is_there_an_emacs_equivalent_to_vimeasyalign/

Here is a link to easy align with instructions:
https://github.com/junegunn/vim-easy-align

Upvotes: 0

mattb
mattb

Reputation: 3053

If you're on linux, you can call an external tool to do the job (no need for a plugin):

:%!column -t

See help range!:

:{range}![!]{filter} [!][arg]                           :range!
                        Filter {range} lines through the external program
                        {filter}...

Upvotes: 3

Related Questions