I'm using vim 7.2.330 on 64 bit ubuntu 10.04, sometime in the last week every time I reopen a file it places the cursor at the top of the file. I can see in ~/.viminfo where it's saving the last position used, but it doesn't seem to be honoring it.

Any ideas?


you can ctrlo to jump through the 'jumps'.

you also add something to your .vimrc to jump to that cursor position automatically, read more at http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session:

" VimTip 80: Restore cursor to file position in previous editing session
" for unix/linux/solaris
set viminfo='10,\"100,:20,%,n~/.viminfo

" only for windows [give some path to store the line number info]
"set viminfo='10,\"100,:20,%,nc:\\Winnt\\_viminfo
 au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  • 1
    What's bothering me is I'm certain it used to remember the position and I didn't do anything in .vimrc to make it do so. And I know my Fedora system it remembers the position in the file without anything in the .vimrc to tell it to. – Neth Dec 3 '10 at 15:14
  • 3
    This is probably due to the fact that some packagers/distributions set the included example vimrc as the system-wide default vimrc, and some don't. That example vimrc contains an autocmd much like the one above. – Heptite Dec 3 '10 at 18:22

In fact, I have observed the same behavior, but with a very different diagnosis.

When my /home/... partition became full, .viminfo was unable to be written, so those file positions were never stored. Once I cleared up some space, viminfo was positioning my editor again.

  • 1
    Also check for permissions+ownership of the ~/.viminfo file – Sukanto Jun 26 '13 at 4:33

Have a look at :help last-position-jump:

This autocommand jumps to the last known position in a file just after opening it, if the '"' mark is set:

:au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif

I tried the above solution, it doesn't work for me... but just by following the below link it worked straight away. Have a look at this vim wiki, seems pretty useful

  • You might want to include the essential points of that link in your answer - if arch changes their wiki's format, you might have an answer that makes no sense. – Journeyman Geek Feb 6 '13 at 12:23
  • What JG said. Also, please be more specific than "the above solution", since the answers change order as they are voted upon. – Isaac Rabinovitch Mar 19 '13 at 3:09

You might want to check the permission and ownership on your ~/.viminfo file. If you had earlier accessed vim via a "sudo -s" or something it's possible that vim cannot write to this file. You might have to chown it back to your group and id.


The vim-lastplace plugin does exactly what you want (I am the author). It improves on the above accepted answer / code snippet by handling commit messages intelligently. If you have debian-testing you can apt-get install vim-lastplace to quickly try it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.