3

Say I opened file X.
then I scrolled down to line number 50 then I made some modifications and closed the file.
when I re-open the file. I want Vim to save the last location in this file (line 50) and puts me in this line automatically.

This feature existed by default. I don't know the name of this feature, so I couldn't google for it. I think I lost it because some plugins have installed later.
How I re-enable this feature again? Thanks.

smalinux
  • 1,132
  • 2
  • 13
  • 28
  • this may be something that could help: https://stackoverflow.com/questions/7894330/preserve-last-editing-position-in-vim – Rob Feb 23 '21 at 10:19
  • 3
    Does this answer your question? [Preserve last editing position in VIM](https://stackoverflow.com/questions/7894330/preserve-last-editing-position-in-vim) – John Schmitt Jun 30 '21 at 23:22

1 Answers1

8

This is done by $VIMRUNTIME/defaults.vim, also explained under :h restore-cursor.

But it's not hard to add this feature yourself:

augroup vimStartup | au!
    autocmd BufRead * call setpos('.', getpos("'\""))
augroup end
Matt
  • 13,674
  • 1
  • 18
  • 27