Created
December 13, 2011 14:22
-
-
Save AndrewRadev/1472282 to your computer and use it in GitHub Desktop.
Simple jumping through buffers
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
| command! -nargs=1 -complete=custom,s:TabjCompletion Tabj call s:Tabj(<f-args>) | |
| function! s:Tabj(name) | |
| for i in range(tabpagenr('$')) | |
| let tabnr = i + 1 | |
| for bufnr in tabpagebuflist(tabnr) | |
| if stridx(bufname(bufnr), a:name) >= 0 | |
| exe 'tabnext '.tabnr | |
| while bufnr('%') != bufnr | |
| wincmd w | |
| endwhile | |
| return | |
| endif | |
| endfor | |
| endfor | |
| echoerr 'Buffer "'.a:name.'" not found' | |
| endfunction | |
| function! s:TabjCompletion(A, L, P) | |
| let buffer_names = {} | |
| for i in range(tabpagenr('$')) | |
| let tabnr = i + 1 | |
| for bufnr in tabpagebuflist(tabnr) | |
| let buffer_names[bufname(bufnr)] = 1 | |
| endfor | |
| endfor | |
| return join(keys(buffer_names), "\n") | |
| endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment