Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to open a file which is closed in line xxx. So I can easily continue editing

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can setup an autocommand that executes when you open a file. If you add this to your .vimrc, that will do it.

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

See :help last-position-jump; this line is pulled straight from there.

share|improve this answer
    
Most vi(m) I know of already do this. They propably have that setting in the global vimrc. Is there any reason to disable that feature? –  Nils Oct 26 '11 at 19:55
1  
According to this, this method doesn't work for one-line files. The link contains another method which does (though it's never been a big deal for me). –  Edd Steel Oct 26 '11 at 22:20
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.