diff options
Diffstat (limited to 'indent/tex.vim')
-rw-r--r-- | indent/tex.vim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/indent/tex.vim b/indent/tex.vim index e7653d03..3abc44ba 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -101,9 +101,21 @@ function! Latexbox_CallIndent() let window = getpos('.') call setpos('.', cursor) + " Get first non-whitespace character of current line. + let line_start_char = matchstr(getline('.'), '\S') + + " Get initial tab position. + let initial_tab = stridx(getline('.'), line_start_char) + " Execute the command. execute 'normal! ==' + " Get tab position difference. + let difference = stridx(getline('.'), line_start_char) - initial_tab + + " Set new cursor Y position based on calculated difference. + let cursor[2] = cursor[2] + difference + " Restore the previous window position. call setpos('.', window) normal! zt |