2

I'm not talking about the previous line I was on while still editing a file but after I close a file and then enter vim again, I want to go to that line. How do I enable this?

Steps to 'reproduce':

vim filename.txt
:234
:q
vim filename.txt
## I want to be on line 234 now, not line 1.
300D7309EF17
  • 121
  • 3
  • For that you need ~/.viminfo file. Please see :help viminfo. This might also help: https://stackoverflow.com/questions/23012391/how-and-where-is-my-viminfo-option-set#32943292 – mas Aug 06 '18 at 01:45
  • yeah, I figured I'd need a viminfo, I've done it in some places, was wondering what the canonical way was to do so. Looks like this comment on that question is really informative: https://stackoverflow.com/a/23036077/659298 – 300D7309EF17 Aug 06 '18 at 01:53
  • One way, maybe: In /etc/vim/vimrc seach for Uncomment the following to have Vim jump to the last position and uncomment the relevant code lines. See this answer. (Also, of course, vim +234 filename.txt) – tomd Aug 06 '18 at 13:33
  • Will flesh out later, but use the 0 mark. – D. Ben Knoble Aug 07 '18 at 00:16

1 Answers1

2

add this to your .vimrc file:

au BufReadPost * if line("'\"") > 0 && line ("'\"") <= line("$") | exe "normal! g'\"" | endif
Aura
  • 151
  • 3