Steven Lu
Steven Lu

Reputation: 43427

Jump to last position in current file

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.

Upvotes: 6

Views: 510

Answers (3)

romainl
romainl

Reputation: 196556

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.

Upvotes: 5

Ingo Karkat
Ingo Karkat

Reputation: 172580

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.

Upvotes: 3

jbr
jbr

Reputation: 6258

You can use marks for what you want. If you pres m+"some lower case letter", eg. m+a. This saves your current cursor position in a. You can then use '+a to jump back to that position. With lower case letters, the mark is saved pr file basis, if you use an upper case letter, then it's valid between open files.

See marks help for more info.

Upvotes: 0

Related Questions