Sunday, August 22, 2010

Re: map "if there are more than one tabpage" then :tabnext else w

On 21/08/10 13:34, Christian Brabandt wrote:
> Hi eliweiq001!
>
> On Fr, 20 Aug 2010, eliweiq001 wrote:
>
>> Hi, I want to write this:
>>
>> map<C-tab> "if there are more than one tabpage" then :tabnext else
>> <C-w>w
>>
>> How to finish it?
>
> Besides the fact, that you can't map<C-Tab> because a Tab is already

Oh, but you can — unless the Ctrl-Tab event doesn't reach Vim, or
reaches it as a plain 0x09.

My gvim can see whether or not Esc, Tab, Enter or Space has been hit
with or without Ctrl and/or Shift: try it, in Insert mode in gvim, by
hitting Ctrl-K followed by Shift-Space, Ctrl-Tab, Shift-Ctrl-Esc, etc.
You'll see the correct <> code inserted in your buffer, even though
Shift-Space normally inserts a space, Esc is Ctrl-[, Tab is Ctrl-I,
Enter is Ctrl-M. I think I've seen a bug fix about that recently (well,
before the 7.3 release obviously) but I can't find it back.

> equal to<C-I> you can use an expression mapping to achieve what you
> want, e.g:
>
> noremap<expr> <f6> tabpagenr('$')>1 ? '<C-PageDown>' :'<C-W>w'
>
> regards,
> Christian
>

if has('windows')
noremap <expr> <C-Tab> <SID>Tab(1)
noremap <expr> <C-S-Tab> <SID>Tab(0)
function s:Tab(fwd)
if tabpagenr('$') > 1
return a:fwd? "\<C-PageDown>" : "\<C-PageUp>"
else
return "\<C-W>" . (a:fwd? "w" : "W")
endif
endfunction
endif


Best regards,
Tony.
--
Labor, n.:
One of the processes by which A acquires property for B.
-- Ambrose Bierce, "The Devil's Dictionary"

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: