Using "Align" plugin without inserting whitespace into email addresses?

12 views
Skip to first unread message

Philip Rhoades

unread,
Apr 30, 2013, 1:00:12 PM4/30/13
to vim...@googlegroups.com
People,

I have been using the "Align" plugin quite happily for a long time now
but I came across a need where it didn't do what I wanted: a block of
lines consisting of only email addresses - I wanted to align on the "@"
character - is there a way to do this without inserting whitespace into
the email addresses? Am I missing something?

Thanks,

Phil.
--
Philip Rhoades

GPO Box 3411
Sydney NSW 2001
Australia
E-mail: ph...@pricom.com.au

Philip Rhoades

unread,
Apr 30, 2013, 1:05:25 PM4/30/13
to vim...@googlegroups.com
People,


On 2013-05-01 03:00, Philip Rhoades wrote:
> People,
>
> I have been using the "Align" plugin quite happily for a long time now
> but I came across a need where it didn't do what I wanted: a block of
> lines consisting of only email addresses - I wanted to align on the
> "@" character - is there a way to do this without inserting whitespace
> into the email addresses? Am I missing something?


What I want to do is to insert spaces preceding the email address to
cause alignment rather than inserting spaces into the email addresses
themselves.

glts

unread,
Apr 30, 2013, 2:24:51 PM4/30/13
to vim...@googlegroups.com, ph...@pricom.com.au
On Tuesday, April 30, 2013 7:00:12 PM UTC+2, Philip Rhoades wrote:
> I have been using the "Align" plugin quite happily for a long time now
>
> but I came across a need where it didn't do what I wanted: a block of
>
> lines consisting of only email addresses - I wanted to align on the "@"
>
> character - is there a way to do this without inserting whitespace into
>
> the email addresses? Am I missing something?

I prefer using Tabular for my alignment tasks.

Using Tabular you would do

:Tab /@/r0c0l0

"/@/" aligns on the @ character, "r0c0l0" is the format specifier,
stating "right-align first column, center-align second column,
left-align third column, all with no padding whitespace".

https://github.com/godlygeek/tabular
http://vimcasts.org/episodes/aligning-text-with-tabular-vim/

Gary Johnson

unread,
Apr 30, 2013, 2:23:39 PM4/30/13
to vim...@googlegroups.com
On 2013-05-01, Philip Rhoades wrote:
> People,
>
>
> On 2013-05-01 03:00, Philip Rhoades wrote:
> >People,
> >
> >I have been using the "Align" plugin quite happily for a long time now
> >but I came across a need where it didn't do what I wanted: a block of
> >lines consisting of only email addresses - I wanted to align on the
> >"@" character - is there a way to do this without inserting whitespace
> >into the email addresses? Am I missing something?
>
>
> What I want to do is to insert spaces preceding the email address to
> cause alignment rather than inserting spaces into the email addresses
> themselves.

First execute

:AlignCtrl rl

then select the lines to align and execute

:Align @

See

:help alignctrl-l

Regards,
Gary

Charles Campbell

unread,
Apr 30, 2013, 2:51:33 PM4/30/13
to vim...@googlegroups.com
> On Tuesday, April 30, 2013 7:00:12 PM UTC+2, Philip Rhoades wrote:
>> I have been using the "Align" plugin quite happily for a long time now
>>
>> but I came across a need where it didn't do what I wanted: a block of
>>
>> lines consisting of only email addresses - I wanted to align on the "@"
>>
>> character - is there a way to do this without inserting whitespace into
>>
>> the email addresses? Am I missing something?
>
You'll want to use

:AlignCtrl p0P0

which tells Align to use zero padding spaces before and zero padding
spaces after each field.

(:help align-p -or- :help align-P )

Regards,
Chip Campbell
Reply all
Reply to author
Forward
0 new messages