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.
  • For that you need ~/.viminfo file. Please see :help viminfo. This might also help: stackoverflow.com/questions/23012391/… – mas Aug 6 '18 at 1: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: stackoverflow.com/a/23036077/659298 – tedder42 Aug 6 '18 at 1: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 6 '18 at 13:33
  • Will flesh out later, but use the 0 mark. – D. Ben Knoble Aug 7 '18 at 0:16
1

add this to your .vimrc file:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.