Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

5 Answers

up vote 5 down vote accepted

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
share|improve this answer
    
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
2  
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
add comment

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.

share|improve this answer
1  
Also check for permissions+ownership of the ~/.viminfo file –  Sukanto Jun 26 '13 at 4:33
add comment

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
share|improve this answer
add comment

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

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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