Created
November 1, 2023 10:09
-
-
Save lericson/99324d94684bd0738d4edff2c60311e9 to your computer and use it in GitHub Desktop.
Vim function: Jump to Previous Buffer in Jumplist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun! JumpPreviousBuffer() | |
let [jumplist, curjump] = getjumplist() | |
let tgtjump = curjump - 1 | |
while 0 <= tgtjump && jumplist[tgtjump]['bufnr'] == bufnr() | |
let tgtjump -= 1 | |
endwhile | |
if tgtjump < 0 | |
echoerr 'No previous buffer in jumplist' | |
return | |
endif | |
execute "normal! " .. (curjump - tgtjump) .. "\<c-o>" | |
endfun | |
nnoremap <Leader>o <Cmd>call JumpPreviousBuffer()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment