, @nodakai CursorMoved - . - - . vimscript.
" Detect movement
augroup CursorChange
autocmd!
autocmd CursorMoved * call OnCursorMoved()
augroup END
" Does the navigation
nnoremap <silent><leader>nb :call NavigateBackward()<cr>
let CursorPositions = []
let PrevJump = []
function! OnCursorMoved()
"echo "Cursor moved to: " . line('.') . ':' . col('.')
"echo g:CursorPositions
let l:current = [line('.'), col('.')]
if (l:current != g:PrevJump) " to prevent getting stuck in a circle
let g:CursorPositions = add(g:CursorPositions, l:current)
endif
endf
function! NavigateBackward()
let l:toIndex = len(g:CursorPositions) - 2 " get target jump position index
if (l:toIndex < 0) | return | endif " make sure it within range
let l:to = g:CursorPositions[l:toIndex] " jump target
let g:PrevJump = l:to " set previous to target
call remove(g:CursorPositions, -1) " remove last position
call cursor(l:to[0], l:to[1]) " jump to target
endf
function! ResetCursorPositions() " for debugging
let g:CursorPositions = [[line('.'), col('.')]]
endf