Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jump to last position in current file

Tags:

vim

I enjoy Ctrl+O quite a bit, but it tends to jump me to other files. The way I work is I have many files open simultaneously across windows and also across different instances of Vim so I can see them at the same time, and switch between them.

So I'd rather have it just jump within a single file. Ideally I can have two separate commands, one that does the normal <C-O> that goes across files (and is like a chronological path of where I have been) and another that does this only in the currently opened file.

Is there perhaps a way to script this? Hopefully there's a plugin out there. I think it would just need to scan through the jumplist filtering out all files that are not this file.

like image 538
Steven Lu Avatar asked Mar 23 '23 18:03

Steven Lu


2 Answers

You can jump though the changelist (:help changelist) with g; (back) and g, (forth).

It is local so there's no way you'd jump to another buffer but it's a "change"list so only changes are remembered, not motions.

like image 178
romainl Avatar answered Apr 20 '23 03:04

romainl


My EnhancedJumps plugin defines variants of <C-o> that either stay in the current buffer, or immediately jump to a cursor position in another buffer.

like image 23
Ingo Karkat Avatar answered Apr 20 '23 05:04

Ingo Karkat