I'm trying to create a function to make editing TSV files easier. The function changes spacing settings, turns off wrapping, and creates a 1 row tall split at the top so that the column headers are always visible.
However I'm having trouble getting the two windows to bind on horizontal scroll. I can get them to bind when executing the commands manually but it doesn't work when I call the function.
fun! TSV()
execute "setlocal nowrap"
execute "setlocal noexpandtab"
execute "setlocal shiftwidth=20"
execute "setlocal softtabstop=20"
execute "setlocal tabstop=20"
" always visible header
execute "sp"
execute "0"
call feedkeys("\<C-W>K")
call feedkeys("1\<C-W>_")
call feedkeys("\<C-W>j")
" bind horizontal scrolling
execute "set scrollopt=hor"
execute "set scrollbind"
call feedkeys("\<C-W>k")
execute "set scrollbind"
call feedkeys("\<C-W>j")
endfun