Monday, August 23, 2010

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

On 23/08/10 09:52, Christian Brabandt wrote:
> Hi Tony!
>
> On Mo, 23 Aug 2010, Tony Mechelynck wrote:
>
>> 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.
>
> Oh it can? But that is only gvim, right? I use console vim on Unix
> exclusively and the console version does not seem to distinguish between
> those two keys.

Then your terminal doesn't pass Ctrl-Tab as other than Tab to
applications running in it, or if it does, its termcap/terminfo hasn't
got the right entry for it, see :help xterm-modifier-keys . No fault of Vim.

The fact that gvim interacts with the keyboard without an intermediary
"terminal" layer trying to interpret the keys, allows it to see more
precisely exactly what the user has typed.

>
>> 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
>
> That's why I think there is a has('gui_running') missing.

Actually, I think that wrapping all that in an :if has('gui_running')
would be too restrictive, in that the key combination may exist in some
terminals.

My Vim, when running in konsole, xterm or the Linux console, would
(IIUC) recognise 0x80 0xFC 0x04 as meaning <C-Tab>, but hitting Ctrl-Tab
in those terminals produces a plain Tab. It might be possible to make
the terminals produce something else by configuring them accordingly.

>
> regards,
> Christian
>

Best regards,
Tony.
--
(letter from Mark to Mike, about the film's probale certificate)
For an 'A' we would have to: Lose as may shits as possible Take Jesus
Christ out, if possible Loose "I fart in your general direction" Lose
"the oral sex" Lose "oh, fuck off" Lose "We make castanets out of
your
testicles"
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

--
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: