Created
May 14, 2011 12:08
-
-
Save ujihisa/972160 to your computer and use it in GitHub Desktop.
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
" kana's useful tab function {{{ | |
function! s:move_window_into_tab_page(target_tabpagenr) | |
" Move the current window into a:target_tabpagenr. | |
" If a:target_tabpagenr is 0, move into new tab page. | |
if a:target_tabpagenr < 0 " ignore invalid number. | |
return | |
endif | |
let original_tabnr = tabpagenr() | |
let target_bufnr = bufnr('') | |
let window_view = winsaveview() | |
if a:target_tabpagenr == 0 | |
tabnew | |
tabmove " Move new tabpage at the last. | |
execute target_bufnr 'buffer' | |
let target_tabpagenr = tabpagenr() | |
else | |
execute a:target_tabpagenr 'tabnext' | |
let target_tabpagenr = a:target_tabpagenr | |
topleft new " FIXME: be customizable? | |
execute target_bufnr 'buffer' | |
endif | |
call winrestview(window_view) | |
execute original_tabnr 'tabnext' | |
if 1 < winnr('$') | |
close | |
else | |
enew | |
endif | |
execute target_tabpagenr 'tabnext' | |
endfunction " }}} | |
" <space>ao move current buffer into a new tab. {{{ | |
nnoremap <silent> <Space>ao :<C-u>call <SID>move_window_into_tab_page(0)<Cr> | |
" }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment