From: Nick Bowler Date: Fri, 3 Feb 2012 14:10:33 +0000 (-0500) Subject: Tighten constraints on line when restoring last file position. X-Git-Url: https://git.draconx.ca/gitweb/vimconf.git/commitdiff_plain/0b203a2db3676d26ab822c52353bc739baff3f75 Tighten constraints on line when restoring last file position. Otherwise, line2byte(1) will returns -1 when opening an empty file, and an error will be produced when trying to jump to that non-existent position. Just require the previous line to be >1 before trying to use it, since changing position to line 1 is pointless anyway. --- diff --git a/plugin/keymap.vim b/plugin/keymap.vim index f53735f..48fe142 100644 --- a/plugin/keymap.vim +++ b/plugin/keymap.vim @@ -17,6 +17,6 @@ let g:leave_my_cursor_position_alone=1 " Jump to last cursor position when editing a file. autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ if line("'\"") > 1 && line("'\"") <= line("$") | \ execute "goto" line2byte(line("'\"")) | \ endif