Loading ...
Sorry, an error occurred while loading the content.

97623Re: Mappings to shift-keys within terminal mode

Expand Messages
  • Gary Johnson
    Nov 3, 2008
      On 2008-11-02, peter holm <peter.g.holm@...> wrote:
      > lör 2008-11-01 klockan 23:30 -0700 skrev Gary Johnson:
      > > On 2008-11-01, peter holm <peter.g.holm@...> wrote:
      > > > I have a few mappings to the shift keys (to mimike the common )
      > > >
      > > > Well - i don't get it to work in terminal.
      > > >
      > > > Any idea?
      > >
      > > In GUI mode, vim is able to see every combination of modifier-key(s)
      > > and symbol-key that the user can press except for those combinations
      > > intercepted by the OS and/or window manager. In terminal mode, vim
      > > doesn't see key combinations directly but sees only sequences of
      > > 7-bit and/or 8-bit characters emitted by the terminal program in
      > > response to key combinations pressed by the user. Most terminal
      > > programs emit unique character sequences for only a limited subset
      > > of all the possible key combinations.
      > >
      > > So it is not surprising that some mappings that work in GUI mode do
      > > not work in terminal mode. That being said, if you post exactly the
      > > mappings you're having problems with, someone here might be able to
      > > offer a solution, or be able to tell you for sure that they won't
      > > work.
      > >
      > > Regards,
      > > Gary
      > >
      > >
      >
      >
      > I had an earlier posting here, named :
      > Select Text without jump between Insert Mode / Visual Mode
      > and a user which name is Martin K. Schreder, kindley enough posted a
      > complete set of mapping to me.
      >
      > Here between the dotted lines is part of our his ansver.
      > ....................................
      > Well, you could do it like this:
      >
      > " switch to visual mode and extend selection upwards
      > :imap <S-Up> <esc>v<Up>
      > " make sure the same key combination works in visual mode
      > :vmap <S-Up> <Up>
      >
      > " do the same for other arrow keys
      > :imap <S-Down> <esc>v<Down>
      > :vmap <S-Down> <Down>
      > :imap <S-Left> <esc>v<Left>
      > :vmap <S-Left> <Left>
      > :imap <S-Right> <esc>v<Right>
      > :vmap <S-Right> <Right>
      >
      > " C-Insert yanks in vis mode and goes back to insert
      > " Remapping C-Insert does not work for me in terminal
      > :vmap <C-Ins> y<esc>i
      > ....................................
      >
      > And here is a link to the complete posting:
      >
      > http://groups.google.com/group/vim_use/browse_thread/thread/12892e26ed72f3f5?pli=1#
      >
      >
      > It's that mapping i really ought to get to work in terminal mode - and
      > hopefully also in xterm and konsole.

      Your terminal and vim together determine which key combinations are
      understood by vim. Vim uses the terminfo database to determine some
      of these; I'm not sure how vim knows about the key combinations not
      defined by terminfo. You can see which key combinations vim
      recognizes by executing

      :set termcap

      For the rxvt terminal I'm using at the moment, vim recognizes
      <Left>, <Right>, <Up>, <Down>, (S-Left> and <S-Right> but not <S-Up>
      or <S-Down>. However, if I enter insert mode and hold the Ctrl key
      while typing the letter v, then type the up arrow, I see that the
      character sequence that the terminal emits for that key is

      ^[OA

      where ^[ indicates the Esc character. If while in insert mode I
      hold the Ctrl key while typing the letter v again, then hold the
      shift key while typing the up arrow, I see that the resulting
      character sequence is

      ^[[a

      So this terminal does emit different character sequences for the
      <Up> and <S-Up> keys. One way to get your mappings to work with
      this terminal would be to also use these mappings:

      :imap <Esc>[a <S-Up>
      :imap <Esc>[b <S-Down>

      You can perform similar experiments with your terminals to see if
      they do emit unique character sequences for those key combinations
      and it so, create mappings as I did. It may also be that some or
      all of those terminals emit the same sequences for the shifted arrow
      keys as they do for the unshifted arrow keys. In that case, you'll
      have to have to use different key combinations for those mappings.

      I hope that was clear enough. See also

      :help i_CTRL-V

      Regards,
      Gary


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 9 messages in this topic