Create a gist now

Instantly share code, notes, and snippets.

@connermcd /example
Last active Oct 5, 2015

What would you like to do?
How to ask for help on #vim
I want to visually select this and hit \t
| thi s | is | a | test | of |
| epic | proportions | that | i'm | trying |
| out | today | as | I | make |
| this | table | with | tabul | arize |
to make it look like this:
thi s is a test of
===== =========== ==== ===== ======
epic proportions that i'm trying
out today as I make
this table with tabul arize
This is what I have:
vnoremap <leader>t :call <SID>table()<cr>
function! s:table()
mark a
let hsepline= substitute(getline("."),'[^|]','=','g')
exe "norm! o" . hsepline
exe "'a,'>s/=|/ |/g"
exe "'a,'>s/|=/| /g"
exe "'a,'>s/^| \\| |$\\||//g"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment