m (includes fairly complex script without that much explanation...mark intermediate complexity) |
(add related script I found accidentally) |
||
Line 70: | Line 70: | ||
nnoremap <A-,> :call MoveToPrevTab()<CR> |
nnoremap <A-,> :call MoveToPrevTab()<CR> |
||
</pre> |
</pre> |
||
+ | |||
+ | ==Related plugins== |
||
+ | * {{script|id=1961|text=Tabmerge}} will merge all the windows of one tab into another |
||
==Comments== |
==Comments== |
Revision as of 14:50, 26 June 2009
created April 18, 2008 · complexity intermediate · author Paluh · version 7.0
These two functions allow you to move window between tabs. Unlike the :tabmove command, which moves an entire tab to a new position, these functions will move a window in the current tab into another existing tab (or a new tab if there are no other existing tabs).
For example, assume you are editing files in three tabs: [1],[2],[3] – where [] indicates a tab page, and the list of numbers inside brackets shows the windows open in that tab (when there is more than one window in one tab, the script splits it horizontally).
Assume that we are in the first tab (so we are editing window with buffer with file 1 – bold marks current window). After :call MoveToNextTab() there will be [1,2],[3]. After the next :call MoveToNextTab() the windows will be arranged thusly: [2][1,3]. And after next one: [2],[3],[1].
Of course MoveToPrevTab() works in opposite direction.
function MoveToPrevTab() "there is only one window if tabpagenr('$') == 1 && winnr('$') == 1 return endif "preparing new window let l:tab_nr = tabpagenr('$') let l:cur_buf = bufnr('%') if tabpagenr() != 1 close! if l:tab_nr == tabpagenr('$') tabprev endif sp else close! exe "0tabnew" endif "opening current buffer in new window exe "b".l:cur_buf endfunc function MoveToNextTab() "there is only one window if tabpagenr('$') == 1 && winnr('$') == 1 return endif "preparing new window let l:tab_nr = tabpagenr('$') let l:cur_buf = bufnr('%') if tabpagenr() < tab_nr close! if l:tab_nr == tabpagenr('$') tabnext endif sp else close! tabnew endif "opening current buffer in new window exe "b".l:cur_buf endfunc
My mapping for them:
nnoremap <A-.> :call MoveToNextTab()<CR> nnoremap <A-,> :call MoveToPrevTab()<CR>
Related plugins
- Tabmerge will merge all the windows of one tab into another
Comments
Absolutelly love this! Thanks!