I mean like CTRL-O
(repeatedly) but limited to the current file only.
Sometimes I check stuff in another file(say using goto definition). And it loads it into the same window.
Still, I want to focus on the current file only.
Thanks
The built-in jump-motions
do not differentiate betweeen buffer-local and "remote" jumps, they just move along the jumplist. You need a custom solution that parses and filters the jumplist.
My EnhancedJumps plugin extends the built-in <C-I>
/ <C-O>
commands with variants that move only within the current buffer (this is what you're asking for), or directly jump to the next position in a different buffer.
let g:EnhancedJumps_CaptureJumpMessages = 0
; it is caused by multiple plugins wanting to use :redir
.
Nov 3, 2018 at 9:37
FYI I wrote this before the question was updated to make it clear that OP wants to jump to the previous location repeatedly. Given that this answer still addresses the question asked in the subject line and has been upvoted a bit I think it's worth leaving here. Cheers.
Generally speaking, marks are used to jump to previously visited locations in the current file.1 To go back to the last visited line or "the position before the last jump" use either ``
, which jumps to the backtick mark, or ''
, jumping to the tick/apostrophe mark. The difference between these two commands is that the former takes you to the last line and column you had been on while the latter takes you to the first non-blank character of that line.
If you want to see where these marks are currently located you can use :marks
, i.e. :marks '
or :marks `
Note that you can actually override these marks, e.g. with m'
, but I'd wager that very few people do that...the defaults are too useful.
BONUS: Tangentially related to your question is this little goody in help: last position jump. It presents an autocommand that you can utilize that upon opening a file will put the cursor at the position it had last been when you last visited that file. (If you are using source $VIMRUNTIME/defaults.vim
in your vimrc file the autocommand is already set up for you.)
1 Marks can also be used to jump file-to-file if uppercase letters are used, e.g. mA
and `A