Created
November 18, 2011 15:46
-
-
Save tmhedberg/1376812 to your computer and use it in GitHub Desktop.
Jump through Vim's jump list one buffer at a time
This file contains hidden or 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
| " Jump backwards or forwards through the jump list one buffer at a time, | |
| " rather than one jump at a time. | |
| " | |
| " Use <Leader>o to jump backwards and <Leader>i to jump forwards | |
| let s:JUMPLIMIT = 100 | |
| if exists('g:loaded_jump_buf') && loaded_jump_buf | |
| finish | |
| endif | |
| let loaded_jump_buf = 1 | |
| function! <SID>jump_buf(back) | |
| let orig_buf = bufnr('%') | |
| let i = 0 | |
| while bufnr('%') == orig_buf && i < s:JUMPLIMIT | |
| execute 'normal!' (a:back ? "\<C-O>" : "1\<C-I>") | |
| let i += 1 | |
| endwhile | |
| let end_buf = bufnr('%') | |
| if a:back && i == s:JUMPLIMIT && end_buf == orig_buf | |
| buffer # | |
| echohl WarningMsg | |
| echomsg 'Jump list limit exceeded; switching to alternate buffer' | |
| echohl None | |
| endif | |
| endfunction | |
| nnoremap <silent> <Leader>o :call <SID>jump_buf(1)<CR> | |
| nnoremap <silent> <Leader>i :call <SID>jump_buf(0)<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment