Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
Moving tabs around with [count]m[N], where [count] is the optional
line number and N is the tab number to move next to. (i.e. after N)
  • Loading branch information
kien committed Jan 28, 2012
1 parent 3687b70 commit 8f2ca92
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
49 changes: 40 additions & 9 deletions autoload/tabman.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fu! s:opts()
for [ke, va] in items(opts)
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
endfo
let s:width_original = s:width
endf

cal s:opts()
Expand All @@ -41,6 +40,10 @@ let s:hlp = [[
\ '" O: go to tab under the',
\ '" cursor, close all',
\ '" others',
\ '"',
\ '" m: move tab under the',
\ '" cursor to after',
\ '" another tab',
\ '" ----------------------',
\ '" <tab>,',
\ '" <right>:',
Expand All @@ -59,10 +62,9 @@ let s:hlp = [[
\ '" previous Tab# line',
\ '" ----------------------',
\ '" r: fix TabMan window',
\ '"',
\ '" <F5>: force update',
\ '" ----------------------',
\ '" <cr>, e, x, b, o, O:',
\ '" <cr>, e, x, b, o, O,',
\ '" m:',
\ '" accept line number',
\ '" as [count]',
\ '" ======================',
Expand All @@ -77,9 +79,9 @@ let [s:maps, s:name, s:lcmap] = [{
\ 'ManOnly(1)': ['O'],
\ 'ManJump(1)': ['l', '<down>'],
\ 'ManJump(-1)': ['h', '<up>'],
\ 'ManMove()': ['m'],
\ 'ManTab(1)': ['<tab>', '<right>'],
\ 'ManTab(-1)': ['<s-tab>', '<left>'],
\ 'ManUpdate(1)': ['<F5>'],
\ 'ManRestore()': ['r'],
\ 'ManHelp()': ['?'],
\ }, 'TabManager', 'nn <buffer> <silent>']
Expand Down Expand Up @@ -129,7 +131,7 @@ fu! s:ManNew()
retu
en
let s:tnew = 1
tabe
exe tabpagenr("$").'tabe'
cal tabman#toggle()
unl s:tnew
endf
Expand Down Expand Up @@ -233,6 +235,36 @@ fu! s:ManJump(dir)
retu
en | endfo
endf

fu! s:ManMove()
let lnr = v:prevcount ? v:prevcount : line('.')
if !has_key(s:btlines, lnr)
retu
en
let oritab = matchstr(s:btlines[lnr], '^\w\zs\d\+')
cal inputsave()
echoh MoreMsg
let newtab = input('Move tab #'.oritab.' to after tab number: ')
echoh None
cal inputrestore()
if newtab =~ '^\d\+$'
let [currwin, s:snew, t:tabman_currtab] = [winnr(), 1, 1]
let newtab = newtab > 0 ? newtab : 0
cal s:ManSelect()
exe 'tabm' newtab
noa tabd
\ if exists('t:tabman_currtab')
\ | let currtab = tabpagenr() |
\ | unl t:tabman_currtab |
\ en
exe 'tabn' currtab '|' currwin.'winc w'
unl s:snew
cal s:ManRestore()
cal s:ManUpdate(1)
en
redr
ec
endf
"}}}
" Render {{{
fu! s:render()
Expand Down Expand Up @@ -317,12 +349,11 @@ fu! s:noupdate()
endf

fu! s:width()
let s:width = s:width_original
if &l:nu
let &l:nuw = strlen(line('$')) + 2
let s:width += &l:nuw
let width = s:width + &l:nuw
en
exe 'vert res' s:width
exe 'vert res' ( exists('width') ? width : s:width )
endf

fu! s:mapkeys()
Expand Down
6 changes: 5 additions & 1 deletion doc/tabman.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# 888 .d888888 888 888 888 Y8P 888 .d888888 888 888 #
# 888 888 888 888 d88P 888 " 888 888 888 888 888 #
# 888 "Y888888 88888P" 888 888 "Y888888 888 888 #
# v1.1 #
# v1.2 #
===============================================================================
CONTENTS *tabman-contents*

Expand Down Expand Up @@ -147,6 +147,10 @@ Once inside the TabMan window:~
[count] is the line number an item is on. If it’s given, the item on line
[count] will be the target of the command.

[count]m[N]
Move the tab under the cursor to after tab page N. If [count] is given,
move the tab at line number [count] to after tab page N.

===============================================================================
CREDITS *tabman-credits*

Expand Down

0 comments on commit 8f2ca92

Please sign in to comment.