-
-
Save bootleq/1061925 to your computer and use it in GitHub Desktop.
See first comment
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
" Modified from kana's useful tab function {{{ | |
function! s:move_window_into_tab_page(...) | |
" Move the current window into target_tabpagenr. | |
" a:1 - target_tabpagenr : if not set, move into new tab page. | |
" a:2 - open_relative : open new tab aside current tab (default 1). | |
let target_tabpagenr = a:0 > 0 ? a:1 : 0 | |
let open_relative = a:0 > 1 ? a:2 : 1 | |
if target_tabpagenr > tabpagenr('$') | |
let target_tabpagenr = tabpagenr('$') | |
endif | |
let original_tabnr = tabpagenr() | |
let target_bufnr = bufnr('') | |
let window_view = winsaveview() | |
if target_tabpagenr == 0 | |
tabnew | |
if ! open_relative | |
tabmove | |
endif | |
execute target_bufnr 'buffer' | |
let target_tabpagenr = tabpagenr() | |
else | |
execute target_tabpagenr 'tabnext' | |
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> | |
" }}} |
Author
bootleq
commented
Jul 3, 2011
- Take arbitrary number of arguments.
- Add argument to open new tab aside current tab.
- Change validation of invalid target_tabpagenr.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment