On Thu, May 21, 2009 at 2:47 PM, Danny wrote:
> On May 21, 2:04 pm, Gary Johnson wrote:
>> On 2009-05-21, Danny wrote:
>>> On Apr 29, 12:25 am, Danny wrote:
>>>> I have been attempting to bind Ctrl+Tab and Ctrl+Shift+Tab as
>>>> the :tabnext and :tabprev commands in vim. From what I have learned,
>>>> PuTTY does not send these commands. I found a post describing how to
>>>> patch putty to send these keys along. (http://scnr.net/blog/index.php/
>>>> archives/61).  However, the keycodes it suggests are not ones that vim
>>>> is expecting. I'm assuming there is some set of keycodes that would be
>>>> appropriate, however I do not know what they are. I'm hoping someone
>>>> here might be able to shed some light on this.
>>>> If anyone is able to lend more information, I'd love to hear it!
>>>
>>> I have yet to find a solution for this problem. If anyone is able to
>>> direct me to any other resources where I might find some answers it'd
>>> be much appreciated!
>>
>> I'm not sure what information you're missing.  No, I didn't read all
>> the references.  As I understand it, you have patched PuTTY to emit
>> unique character sequences for each of Tab, Ctrl+Tab and
>> Ctrl+Shift+Tab.  The next step is to run vim in that PuTTY, enter
>> insert mode, type Ctrl-V, then type Tab, then Enter.  Repeat this
>> for Ctrl+Tab, Ctrl+Shift+Tab, and for my own curiosity, Shift+Tab.
>> The result should be four lines of character sequences.  You may
>> need to ":set list" to see the Tab in the first line.  The four
>> lines should contain unique sequences.  If they're not unique, vim
>> will have no way to distinguish among them.  That problem would have
>> to be fixed within PuTTY.
>>
>> The terminal I'm using at the moment generates the following
>> sequence when I type Ctrl-V followed by Shift-Tab:
>>
>>     ^[[Z
>>
>> where the leading ^[ pair represents the single character Escape and
>> appears in blue on my terminal.
>>
>> Assuming at this point that PuTTY does generate sequences of
>> characters when Ctrl+Tab and Ctrl+Shift+Tab are typed and that these
>> sequences are different from those generated by any other key
>> combination you care about, here's how you would map the first to
>> the :tabnext command.  First type
>>
>>     :nnoremap
>>
>> followed by a space, then Ctrl-V, then Ctrl+Tab, another space, then
>>
>>     :tabnext<CR>
>>
>> That should do it.  Mapping Ctrl+Shift+Tab is done the same way.

Hm.  One comment would be that using a mapping for this isn't such
a good idea; it would be much better to use the method mentioned at
:help :set-termcap

The examples here might be very helpful for that:
http://vim.wikia.com/wiki/VimTip1272

> Yup, those suggestions helped! Thanks for the guidance there, I had
> the pieces I just wasn't connecting them together properly.  I was
> having difficulty with the fact that the scnr.net link used "^
> [[27;5;9~" as an escape sequence. As far as I know Vim was only
> recognizing up to the first set of digits. Changing it to something
> like "^[[1337" works.
>
> 1 ^I$           #tab
> 2 ^[[Z$         #shift-tab
> 3 ^[[1337$      #ctrl-tab
> 4 ^[[1334$      #ctrl-shift-tab

No such limitation exists.  Vim has no problem reading past a semicolon,
in fact, lots of well-recognized keycodes will have semicolons in them.
For instance, ^[[1;5D is ctrl-left.

> My other question though I am still wondering about. What is the
> "correct" escape sequence to duplicate those keyboard commands. I
> mean, Vim already has representations for <C-Tab> and <C-S-Tab>, but
> how do I figure out what those are? Although not necessary, I'd like
> to be able to send the keybindings that vim is actually expecting.

Terminal vim doesn't necessarily expect the right thing.  That being
said, for <Tab>, only ^I is correct.  For <S-Tab>, either ^[[Z or
^[[27;2;9~ is correct.  For <C-Tab>, only ^[[27;5;9~ is correct, and for
<C-S-Tab>, only ^[[27;6;9~ is correct (vim recognizes neither of these).

In general, the most robust method for representing any keystroke is
CSI 27 ; (modifier mask + 1) ; (decimal number of modified key) ~
where the modifier mask is +1 for shift, +2 for alt, +4 for ctrl - but
vim can't understand keycodes of that type.

~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to