From 271b63d71707720ad0d35590b8cb50f8f8f43014 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 11 May 2015 15:05:13 +0200 Subject: Update --- indent/tex.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indent/tex.vim') 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 -- cgit v1.2.3