I have a function called AlignText that works like if you were using the "column" command. If you pass a separator it will use it as separator, if not it will function like normal column command.
" https://stackoverflow.com/questions/57093175/
" https://vi.stackexchange.com/questions/2410/
if !exists('*AlignText')
function! AlignText(...) range
if a:0 < 1
execute a:firstline . ',' . a:lastline . '!column -t'
else
execute a:firstline . ',' . a:lastline . '!column -t -s' . a:1 . ' -o' . a:1
endif
endfunction
endif
command! -range=% -nargs=? Align <line1>,<line2>call AlignText(<f-args>)
If you select a portion it will work on that if not the whole file will be changed
vip ........................... visual inner paragraph
:'<,'>Align ................... apply change on selected paragraph
You can copy the function and the "command!" to the clipboard and run on vim:
:@+ ....................... will put the function into vim memory
vip ....................... select your block of text
:'<,'>Align ............... voila, text aligned
The actual "column" command can be used this way:
vip ....................... select the paragraph
:'<,'>!column -t