Created
October 25, 2009 11:21
-
-
Save hokaccha/218008 to your computer and use it in GitHub Desktop.
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
" ウインドウ単位で開いたファイルの履歴をたどる | |
function! FileJumpPush() | |
if !exists('w:histories') | |
let w:histories = [] | |
endif | |
let buf = bufnr('%') | |
if count(w:histories, buf) == 0 | |
call add(w:histories, buf) | |
endif | |
endfunction | |
function! FileJumpPrev() | |
if exists('w:histories') | |
let buf = bufnr('%') | |
let current = match(w:histories, '^'.buf.'$') | |
if current != 0 && exists('w:histories[current - 1]') | |
execute 'buffer ' . w:histories[current - 1] | |
endif | |
endif | |
endfunction | |
function! FileJumpNext() | |
if exists('w:histories') | |
let buf = bufnr('%') | |
let current = match(w:histories, '^'.buf.'$') | |
if exists('w:histories[current + 1]') | |
execute 'buffer ' . w:histories[current + 1] | |
endif | |
endif | |
endfunction | |
augroup FileJumpAutoCmd | |
autocmd! | |
augroup END | |
autocmd FileJumpAutoCmd BufReadPre * call FileJumpPush() | |
nnoremap <silent> ,p :<C-u>call FileJumpPrev()<CR> | |
nnoremap <silent> ,n :<C-u>call FileJumpNext()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment