junegunn / vim-easy-align

:sunflower: A Vim alignment plugin
4.12k stars 120 forks source link

how to align sprit character? #142

Open wuqingze opened 4 years ago

wuqingze commented 4 years ago

for example, how can I change

System.out.println("hello world 1"); // hello1 
System.out.println("hello 2"); // hello2

to

System.out.println("hello world 1"); // hello1 
System.out.println("hello 2");       // hello2
hberge commented 1 month ago

I struggled a bit with the same. The reason it doesn't take the pattern is that it is inside a comment.

I edited the s:easy_align_delimiters_default table in autoload/easy_align.vim and added the pattern there, where I could add 'ignore_groups':['!Comment'] at the end.

The below line worked for me, and it also checks for an optional ! flag

\  'c': { 'pattern': '//[ !]\?',  'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0, 'ignore_groups':['!Comment']},