I don't believe this is possible directly via Tabular. However, you can define a wrapper command that accepts the desired string as an argument:
command! -nargs=1 First exec 'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
You can then execute First
with any character, e.g. :First =
and :First |
, or even longer strings, e.g. :First ||
and :First &&
.
In case this better suits your use case, you can also define mappings that use the current selection (in normal mode, the character under the cursor) as the argument:
vnoremap <F3> y \| :exec 'Tabularize /^[^' . escape(getreg('"'), '\^$.[?*~') . ']*\zs' . escape(getreg('"'), '\^$.[?*~')<CR>
nnoremap <F3> yl \| :exec 'Tabularize /^[^' . escape(getreg('"'), '\^$.[?*~') . ']*\zs' . escape(getreg('"'), '\^$.[?*~')<CR>
Edit: In order to allow for ranges, add the -range
attribute to the command definition and pass <line1>
(beginning) and <line2>
(end) on to Tabularize
:
command! -nargs=1 -range First exec <line1> . ',' . <line2> . 'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')