2

I'm loving the fact that I can jump using relative numbers and a movement command but I always seem to find myself using the backticks to try and go back to where I was before the movement jump.

I know that movement isn't added to the jump list and I agree with that if it's just a single movement but if it's a numbered jump (more than one) I feel like it should be added to the jump list. So my question is how do I do this?

1

Edit didn't realize someone posted the same answer in a comment rather than just posting an answer.

Per a post on /r/vim, you can add numbered jumps by setting the previous context mark. These two lines will only set the mark when jumping more than 1 time (i.e. must be numbered like 3k or 20j)

nnoremap <expr> k (v:count > 1 ? "m'" . v:count : '') . 'k'
nnoremap <expr> j (v:count > 1 ? "m'" . v:count : '') . 'j'

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.