I'm sure this could be simplified but it worked for your example case:
:Tabularize/@\w\+\s\+\zs\S\+\|\%(@\w\+.*\)\@<=\u.*/
Overview
The key to this is to pick good deliminators to split on because we want to align the @return
line as well as the @param
lines. Use Tabularize to split on the start of the WORD after an @
-word and the first uppercase letter.
Explanation
\|
creates a branches in a regex pattern. This means we can split on both deliminators@\w\+
matches@
followed by a word. e.g.@param
\zs
set the start of the match@\w\+\s\+\zs\S\+
match an@
-word followed by a WORD and set the start of the match a the start of the WORD\u
match an uppercase letter\u.*
match the uppercase letter followed the rest of the line to prevent more splits\%(...\)
a non-capturing group\@<=
is vim's positive look behind.\(foo\)\@<=bar
matchesbar
afterfoo
infoobar
\%(@\w\+.*\)\@<=\u
match an uppercase letter that follows an@
-word
Common Tabular alignment idioms
- use
\zs
to set the start of a match - end with
.*
to consume the rest of the line and prevent more splitting
For more help see:
:h :Tabularize
:h /\|
:h /\S
:h WORD
:h /\zs
:h /\u
:h /\%(
:h /\@<=