usage

useful commands

command! -nargs=0 -bar -range=% Reverse
    \       let save_mark_t = getpos("'t")
    \<bar>      <line2>kt
    \<bar>      exe "<line1>,<line2>g/^/m't"
    \<bar>  call setpos("'t", save_mark_t)
nnoremap <Leader>r :Reverse <bar> nohlsearch<CR>
xnoremap <Leader>r :Reverse <bar> nohlsearch<CR>

command! -nargs=0 DocTocUpdate execute 'silent !/usr/local/bin/doctoc --notitle --update-only --github --maxlevel 3 %' | execute 'redraw!'
command! -nargs=0 DocTocCreate execute 'silent !/usr/local/bin/doctoc --notitle --github --maxlevel 3 %' | execute 'redraw!'
command! -nargs=1        First execute                           'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
command! -nargs=1 -range First execute <line1> . ',' . <line2> . 'Tabularize /^[^' . escape(<q-args>, '\^$.[?*~') . ']*\zs' . escape(<q-args>, '\^$.[?*~')
command! -nargs=0        Iname execute 'echo expand("%:p")'

[!TIP|label:references:]

specifier
comments

l<N>

left-align (with N spaces padding)

r<N>

right-align (with N spaces padding)

c<N>

center-align (with N spaces padding)

:Tabularize /,/r1c1l0 means:

  • splitting fields on commas (:)

  • print everything before the first comma right aligned, then 1 space

  • then the comma center aligned, then 1 space,

  • then everything after the comma left aligned.

  • including the <sep>

    • align to left

      • or

    • align to center

    tabularize
  • align without <sep>

    [!NOTE] help /zs

align with the N pattern

i.e.: the second match (=)

[!NOTE|label:pre condition:]

  • align the first : and last matches , as below:

  • first :

    reference: via

    • /^[^;]*\zs:

    • /^[^;]*\zs:/r1c1l0

    • /^[^;]*/r1c1l0

    • /^[^:]*\zs:

      tabularize-1
      tabularize-2
    • /^[^:]*\zs/r1c1l0

    • /^[^:]*\zs:/r1c1l0

      tabularize-3
    • /^[^:]*/r1c1l0

    • /^[^:]*:/r1c1l0:

  • last ,

    tips:

    • actually the pattern not matches with the final ,, but matches with )<.*> ,

    sample code:

    • /)[^,]*\zs,

      • or even better align

        • :1,3Tabularize /, or :'<,'>Tabularize /,

        • :Tabularize /)[^,]*\zs,

      tabularize-4

Last updated

Was this helpful?