Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My Ubuntu LTS 12.04 has vim editor. If I open a file, move to a paragraph and reopen vim, then the cursor goes to beginning of the file always.

This is not the expected behavior. How the vim can remember last read position after closing a file ?

I tried vi also , but the result is the same :-(

share|improve this question
1  
I am sorry, but there seems to be 0 documentation that says it should. Are you 100% sure thats the case for Vim ? And, i am sorry, i got no idea how to configure it to remember last position. Might an unnecessary comment by me, but i gotta know if you experienced the program doing that earlier. –  denNorske Nov 28 '12 at 13:32
    
"This is not the expected behavior." -- explain why. –  gertvdijk Nov 28 '12 at 14:24
1  
For example in Redhat , the last refereed line in a file is remembered by vim. vim seems to be inconvenient in ubuntu 12.04 –  Lunar Mushrooms Nov 28 '12 at 14:34
    
Also in Ubuntu 10.04 this is certainly not default behaviour. I've been using Vim on Ubuntu for a long time, never saw your expected behaviour. You probably have configured it to do so on that installation - see the answer of @GaryBishop for example. –  gertvdijk Nov 28 '12 at 14:37
    
Sorry it was not Ubuntu 10.04 , it was red hat that worked. Updated my comment –  Lunar Mushrooms Nov 28 '12 at 14:42
add comment

4 Answers

up vote 10 down vote accepted

Resolved it :

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

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

share|improve this answer
add comment

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

share|improve this answer
add comment

I have the same problem,It seem that vim is not install when I try to install vim I get this:

$ sudo aptitude reinstall vim
vim is not currently installed, so it will not be reinstalled.
vim is not currently installed, so it will not be reinstalled.

after i installed vim:

$ sudo aptitude install vim

It's working!

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.