Go to middle of line in vim
:call cursor(0, len(getline('.'))/2)
Typing gm
would do it, but it moves by screen lines (see :help gm
). In order to get it working with text lines, one can remap this command:
map gm :call cursor(0, virtcol('$')/2)<CR>
Here is a solution that will respect hardtabs, and multi-bytes characters as well.
:exe 'normal '.(virtcol('$')/2).'|'