Skip to content

Instantly share code, notes, and snippets.

@digital-carver
Last active August 27, 2015 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digital-carver/668e7bb496f1fc20f2fc to your computer and use it in GitHub Desktop.
Save digital-carver/668e7bb496f1fc20f2fc to your computer and use it in GitHub Desktop.
An `after/plugin` function for Tabular.vim to allow PCRE (using eregex.vim)
if exists(':E2v')
function! AlignByRE() range
let range = a:firstline . ',' . a:lastline
let cmd = range
let re = input('Enter PCRE to align by: ')
if re == ""
" Run empty to use previous pattern
let cmd .= 'Tabularize'
execute cmd
else
let vim_re = E2v(re)
let cmd .= 'Tabularize/' . vim_re
endif
execute cmd
endfunction
nnoremap <leader>A :call AlignByRE()<CR>
vnoremap <leader>A :call AlignByRE()<CR>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment