Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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
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

Your Answer


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.