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

Re: Is there already a solution for mapping in Terminal (urxvt)?

Expand Messages
  • Tony Mechelynck
    For some reason, the message arrived garbled when sent in Latin1 so I m sending it again, but in UTF-8 this time. ... To make Vim tell apart mappings,
    Message 1 of 6 , Apr 2, 2013
      For some reason, the message arrived garbled when sent in Latin1 so I'm
      sending it again, but in UTF-8 this time.

      On 02/04/13 22:47, Kent wrote:
      > Hi everybody,
      >
      > I knew this is not a new topic. I had that problem years ago, tried a
      > lot and finally gave up. Recently, I went through my vimrc, and found
      > my very old commented out codes:
      >
      > "mapping <a-j> in unxvt doesn't work, gave up!!
      >
      >
      > about 3,4 years have past, I did some tests just now, it still didn't
      > work. What I want to map is simple, <a-j/k> move current line up/down.
      >
      > The mapping is easy. point is how to make <alt> work.
      > what I tried: (e.g <a-j>)
      >
      > set timeout timeoutlen=1000 ttimeoutlen=100
      > set <m-j>=^[j (c-v then a-j)
      > inoremap <m-j> <Esc>:m+<CR>==gi
      >
      > this works, problem is if in Insert mode I press<esc> to back to
      > normal mode and `j` to next line, vim does above mapping, which stops
      > switching to Normal, but move the current line down and stay in Insert
      > mode. The ttimeout=100 didn't seem to work.. no idea why.
      >
      > also tried :
      >
      > set timeout timeoutlen=1000 ttimeoutlen=100
      > set <m-j>= ^[j
      > imap ^[ j <m-j>
      > inoremap ^[ j <Esc>:m+<CR>==gi
      >
      > it prints the "ê"
      >
      > Is there already a working solution for it?
      >
      > thanks
      >
      > Kai
      >

      To make Vim tell apart mappings, multibyte key codes, and successive
      keypresses, see
      :help 'timeout'
      :help 'timeoutlen'
      :help 'ttimeout'
      :help 'ttimeoutlen'
      :help 'showcmd'

      I recommend using

      :set timeout timeoutlen=5000 ttimeoutlen=100 showcmd

      in your vimrc, but these values (where numbers are in milliseconds) are
      what I'm comfortable with; they may vary according to your patience and
      typing speed, and to the speed of your keyboard connection, so read the
      help.

      Note also that <Alt>+some-printable-key is stored internally as the
      printable key OR 0x80, so ê (0xEA) is <Alt> + j (because j is 0x6A). See
      also
      :help 'esckeys'
      :help :map-alt-keys


      Best regards,
      Tony.
      --
      Beware of self-styled experts: an ex is a has-been, and a spurt is a
      drip under pressure.

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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • LCD 47
      On 2 April 2013, Kent wrote: [...] ... [...] The keyboard bindings for in urxvt depend on the URxvt.meta8 resource. If URxvt.meta8
      Message 2 of 6 , Apr 3, 2013
        On 2 April 2013, Kent <kent.yuan@...> wrote:
        [...]
        > What I want to map is simple, <a-j/k> move current line up/down.
        [...]

        The keyboard bindings for <ALT> in urxvt depend on the URxvt.meta8
        resource. If URxvt.meta8 is false (which is the default), <ALT><key>
        sends <ESC><key> and thus you need to write your maps for <ESC>mumble:

        nnoremap <Esc>j "zdd"zp
        nnoremap <Esc>k k"zdd"zpk

        If URxvt.meta8 is true, <ALT><key> sends an 8-bit character and sens
        the Meta flag, which means you have to write your maps for <M-mumble>:

        nnoremap <M-j> "zdd"zp
        nnoremap <M-k> k"zdd"zpk

        In order to change the URxvt.meta8 resource, either add

        *URxvt.meta8: true

        to /etc/X11/app-defaults/URxvt (the path may differ on your machine), or
        add

        URxvt.meta8: true

        to ~/.Xresources (and run "xrdb -merge ~/.Xresources" for it to take
        effect immediatley).

        The xterm equivalent of URxvt.meta8 is VT100.metaSendsEscape.

        /lcd

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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Tony Mechelynck
        ... …or to be precise, !(vt100.metaSendsEscape) of course (the one is true when the other is false, to give the same meaning). ... Best regards, Tony. -- New
        Message 3 of 6 , Apr 3, 2013
          On 03/04/13 09:49, LCD 47 wrote:
          > On 2 April 2013, Kent <kent.yuan@...> wrote:
          > [...]
          >> What I want to map is simple, <a-j/k> move current line up/down.
          > [...]
          >
          > The keyboard bindings for <ALT> in urxvt depend on the URxvt.meta8
          > resource. If URxvt.meta8 is false (which is the default), <ALT><key>
          > sends <ESC><key> and thus you need to write your maps for <ESC>mumble:
          >
          > nnoremap <Esc>j "zdd"zp
          > nnoremap <Esc>k k"zdd"zpk
          >
          > If URxvt.meta8 is true, <ALT><key> sends an 8-bit character and sens
          > the Meta flag, which means you have to write your maps for <M-mumble>:
          >
          > nnoremap <M-j> "zdd"zp
          > nnoremap <M-k> k"zdd"zpk
          >
          > In order to change the URxvt.meta8 resource, either add
          >
          > *URxvt.meta8: true
          >
          > to /etc/X11/app-defaults/URxvt (the path may differ on your machine), or
          > add
          >
          > URxvt.meta8: true
          >
          > to ~/.Xresources (and run "xrdb -merge ~/.Xresources" for it to take
          > effect immediatley).
          >
          > The xterm equivalent of URxvt.meta8 is VT100.metaSendsEscape.

          …or to be precise, !(vt100.metaSendsEscape) of course (the one is true
          when the other is false, to give the same meaning).

          >
          > /lcd
          >

          Best regards,
          Tony.
          --
          New Hampshire law forbids you to tap your feet, nod your head, or in
          any way keep time to the music in a tavern, restaurant, or cafe.

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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Kent
          thanks Tony, thanks LCD 47 I just did some test again, didn t find solution... :( I think the mapping works here. my problem is the keycode timeout..
          Message 4 of 6 , Apr 3, 2013
            thanks Tony, thanks LCD 47

            I just did some test again, didn't find solution... :(

            I think the <alt-j> mapping works here. my problem is the keycode timeout..

            Normal mode mapping I have no problem, but Insert mode ....

            let's say, I tried followings:
            inoremap ^[j <Esc>:m-2<CR>==gi (c-v then alt-j)
            or
            inoremap <esc>j <Esc>:m-2<CR>==gi

            with this mapping when i am in insert mode, and press <alt -j>,
            current line moved down, (format ==) then stay in Insert mode.
            This works no problem.

            The annoying thins is, now I am in Insert mode, I want to press <esc>
            back to Normal, and press j, move to next line (Normal mode). vim does
            what I mapped above, not back to Normal mode.... even if I have
            set timeout timeoutlen=1000 ttimeoutlen=100

            why this 100ms doesn't work here... I don't know why.

            I tried to add URxvt*meta8:true in ~/.Xresources as well. I could
            directly map (Insert mode) <m-j> ... but when I type <alt-j> a "ê"
            printed. I think this is what Tony meant. I also read about set
            tenc=latin1 could fix it. it do fix it, but I cannot input multi-bytes
            characters also utf-8 file with mutl-bytes letter/words cannot be
            displayed. e.g. CJK

            I also tried the way in
            http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim, didnt
            make it work...

            any more suggestions? or where I did wrong?



            On Wed, Apr 3, 2013 at 10:05 AM, Tony Mechelynck
            <antoine.mechelynck@...> wrote:
            > On 03/04/13 09:49, LCD 47 wrote:
            >>
            >> On 2 April 2013, Kent <kent.yuan@...> wrote:
            >> [...]
            >>>
            >>> What I want to map is simple, <a-j/k> move current line up/down.
            >>
            >> [...]
            >>
            >> The keyboard bindings for <ALT> in urxvt depend on the URxvt.meta8
            >> resource. If URxvt.meta8 is false (which is the default), <ALT><key>
            >> sends <ESC><key> and thus you need to write your maps for <ESC>mumble:
            >>
            >> nnoremap <Esc>j "zdd"zp
            >> nnoremap <Esc>k k"zdd"zpk
            >>
            >> If URxvt.meta8 is true, <ALT><key> sends an 8-bit character and sens
            >> the Meta flag, which means you have to write your maps for <M-mumble>:
            >>
            >> nnoremap <M-j> "zdd"zp
            >> nnoremap <M-k> k"zdd"zpk
            >>
            >> In order to change the URxvt.meta8 resource, either add
            >>
            >> *URxvt.meta8: true
            >>
            >> to /etc/X11/app-defaults/URxvt (the path may differ on your machine), or
            >> add
            >>
            >> URxvt.meta8: true
            >>
            >> to ~/.Xresources (and run "xrdb -merge ~/.Xresources" for it to take
            >> effect immediatley).
            >>
            >> The xterm equivalent of URxvt.meta8 is VT100.metaSendsEscape.
            >
            >
            > …or to be precise, !(vt100.metaSendsEscape) of course (the one is true when
            > the other is false, to give the same meaning).
            >
            >>
            >> /lcd
            >>
            >
            > Best regards,
            > Tony.
            > --
            > New Hampshire law forbids you to tap your feet, nod your head, or in
            > any way keep time to the music in a tavern, restaurant, or cafe.
            >
            >
            > --
            > --
            > 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
            >
            > --- You received this message because you are subscribed to the Google
            > Groups "vim_use" group.
            > To unsubscribe from this group and stop receiving emails from it, send an
            > email to vim_use+unsubscribe@....
            > For more options, visit https://groups.google.com/groups/opt_out.
            >
            >

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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.