Hello Vim developers, After reading a discussion on improving the following snippet mentioned in :help last-position-jump
:au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif in the Vim Tips Wiki (http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session), I found out that restoring the last editing position via g`" doesn't work when that position is on line 1 and the file is opened from within Vim (e.g. via :edit {file}), as opposed to when it is directly passed to Vim via vim {file}. Steps to reproduce: #v+ $ vim -N -u NONE foo :normal! iThis is a test. :wq # Working: $ vim -N -u NONE --cmd 'autocmd BufReadPost * normal! g`"' --cmd 'autocmd BufReadPost * echo getpos(".")' foo [0, 1, 15, 0] :echo getpos('.') [0, 1, 15, 0] :q # Broken: $ vim -N -u NONE --cmd 'autocmd BufReadPost * normal! g`"' --cmd 'autocmd BufReadPost * echo getpos(".")' :edit foo [0, 1, 15, 0] :echo getpos('.') [0, 1, 1, 0] :q #v- (The second autocmd has been added only for illustration purposes.) As you can see, the autocmd seems to successfully restore the position to column 15, but then the column is somehow changed to column 1. Last-change positions on line 2 and higher are restored correctly, with either method of opening the file. I can reproduce this on Vim 7.3.107 (Big version with GTK2 GUI) on Linux/x86 as well as GVIM 7.3 and GVIM 7.0 on Windows/x86. -- regards, ingo -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php