vim is not remembering last position

The file /etc/vim/vimrc already contains necessary feature. Just need to uncomment it:

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

(Infact, you can refer to /usr/share/vim/vim73/vimrc_example.vim also)


I had this same problem and it turned out that the .viminfo file in my home directory had the wrong ownership. It was owned by root:root.

Once I fixed the file ownership by changing it to myself, remembering file position started working for me again


I think this wiki posting may provide a solution. I don't believe restoring the position is the expected behavior. http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session

Tags:

Vi

Vim

12.04