user1002430
user1002430

Reputation:

How to use vim-easy-align to align vimscript comments?

I'm trying to use vim-easy-align to align vimscript comments. For example, turn this:

Plugin 'ervandew/supertab' " Tab completion
Plugin 'kien/ctrlp.vim' " File searching
Plugin 'lervag/vimtex' " LaTeX

to:

Plugin 'ervandew/supertab' " Tab completion
Plugin 'kien/ctrlp.vim'    " File searching
Plugin 'lervag/vimtex'     " LaTeX

I'm trying vipga, then ^X (for regex), then " (double quote), and it executes but does nothing. Also tried visually selecting rows, then ga, ^X, " which also does nothing.

With Tabular, it's simply :Tabular /" but I cannot figure it out with vim-easy-align. What am I doing wrong?

Upvotes: 1

Views: 1370

Answers (2)

sjw
sjw

Reputation: 102

I believe by default, vim-easy-align will ignore strings, using the ignore_groups option. Pressing Ctrl+G will toggle through the options for ignore_group. Pressing it once, the first option is to have no groups ignored.

The command to perform the alignment you desire is therefore

gaip^G"<CR>

Upvotes: 2

Erick Garcia
Erick Garcia

Reputation: 21

To align with easy-align inline-comments you can follow the instructions in here: https://github.com/junegunn/vim-easy-align/blob/master/EXAMPLES.md

as the example illustrates to align inline-comments it does not matter if it is vimscript. The commands are

vipga-<space>

vip: select the whole line block

ga: easy-align mapping

-< space >: aligns inline-comments

hopefully this helps to anyone who had a hard time like me

Upvotes: 2

Related Questions