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

Re: [vim] Friggin' Alt Keys...

Expand Messages
  • Charles E. Campbell
    ... Looks like I m still learning about vim! However, your example didn t work. In fact, a number of things I tried didn t work, but here s ... Anyway, I d
    Message 1 of 13 , Nov 1, 2002
    • 0 Attachment
      On Thu, Oct 31, 2002 at 07:04:01PM -0500, jproctor@... wrote:
      >
      > How does mapping Ctrl-V Ctrl-V Ctrl-V Alt-A to <M-a> differ from using
      > set <M-a> Ctrl-V Alt-a
      >
      > Using set prevents having to do it for map, imap, etc.
      >
      > Also, I had to add the following to my vimrc for meta keys to work well since
      > <M-j> in insert mode was sometimes interpredted as <Esc> j, or end insert and
      > move down a line.
      >
      > set notimeout
      > set ttimeout
      > set ttimeoutlen=20
      >
      > Is your way better?
      ---------------------------------------------------------------------

      Looks like I'm still learning about vim! However, your example didn't
      work. In fact, a number of things I tried didn't work, but here's
      one that finally did:

      :exe "set <m-a>=\<esc>[087q"

      Ones that don't work:

      :set <m-a>=<esc>[087q
      :set <m-a>=
      :set <m-a>=
      :set <m-a>=
      :set <m-a>="<esc>[087q"
      :set <m-a>="\<esc>[087q"
      :set <m-a>=""
      :set <m-a>=""
      :set <m-a>=""

      Anyway, I'd say the set method is better, but it isn't obvious how
      to get it to work.

      Regards,
      C Campbell

      --
      Charles E Campbell, Jr, PhD _ __ __
      Goddard Space Flight Center / /_/\_\_/ /
      cec@... /_/ \/_//_/
      PGP public key: http://www.erols.com/astronaut/pgp.html
    • Bram Moolenaar
      ... No, Vim can t see the difference between quickly typing an and then j and getting the same characters from typing Meta-j. The best solution is to
      Message 2 of 13 , Nov 1, 2002
      • 0 Attachment
        Arker wrote:

        > Doh! Problem with this seems to be that now when I do something like
        > leaving Insert mode by way of the <Esc> key, if the first thing I try to
        > do is move down, Vim executes whatever is bound to <M-j>. Same with all
        > other keys that have a meta binding.
        >
        > Pretty ugly..haha. Is there a way to get Vim to ignore the metas comming
        > from the <Esc> key?

        No, Vim can't see the difference between quickly typing an <Esc> and
        then "j" and getting the same characters from typing Meta-j.

        The best solution is to avoid that the terminal emulator sends Meta/Alt
        keys by prepending <Esc>.

        --
        TIM: To the north there lies a cave, the cave of Caerbannog, wherein, carved
        in mystic runes, upon the very living rock, the last words of Olfin
        Bedwere of Rheged make plain the last resting place of the most Holy
        Grail.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\
        \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
        \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
      • Charles E. Campbell
        ... Nothing -- its just that vim normally interprets to mean the a |0x80 ; ie., in binary, v a is 0b01100001 is 0b11100001 ^ However, many
        Message 3 of 13 , Nov 1, 2002
        • 0 Attachment
          On Thu, Oct 31, 2002 at 07:17:47PM -0500, Arker wrote:
          > But now I'm curious, what is the problem with my machine?

          Nothing -- its just that vim normally interprets <m-a> to mean the
          "'a'|0x80" ; ie., in binary,

          v
          'a' is 0b01100001
          <m-a> is 0b11100001
          ^

          However, many keyboards produce different things for the alt-keys. I
          presume termcap/terminfo entries could make this clear but usually
          don't.

          Regards,
          C Campbell

          --
          Charles E Campbell, Jr, PhD _ __ __
          Goddard Space Flight Center / /_/\_\_/ /
          cec@... /_/ \/_//_/
          PGP public key: http://www.erols.com/astronaut/pgp.html
        • Arker
          If anyone else is having the same problem with their Alt keys not working properly in Vim, here is a nice answer. Go and read here:
          Message 4 of 13 , Nov 2, 2002
          • 0 Attachment
            If anyone else is having the same problem with their Alt keys not
            working properly in Vim, here is a nice answer. Go and read here:

            http://mywebpage.netscape.com/bbenjif/vim/Riehm/doc/meta.keys.html#tests

            This fixed the problem in minutes without anything added to my .vimrc
            file and appears to have no side effects**. The only problem, which
            really isn't a problem at all, is that terminals like aterm and
            gnome-terminal don't appear to see these new settings although I'm sure
            if you looked, there is likely a CLI switch in their man pages that will
            fix that. Running 'xterm' works perfectly, and so does gvim.

            Thanks to all who have offered help from this list though. I just
            thought I'd share the wealth.

            Cheers,

            Dennis Craven

            ** I use the words 'appears to have no side effects' because I have only
            been using it for a day and a half. So far it has only worked perfectly.
          • jproctor@prium.net
            For me, this works fine on multiple linux distros running in an xterm or equivalent, as well as, gvim. set notimeout set ttimeout set timeoutlen=20 set
            Message 5 of 13 , Nov 5, 2002
            • 0 Attachment
              For me, this works fine on multiple linux distros running in an xterm or
              equivalent, as well as, gvim.

              set notimeout
              set ttimeout
              set timeoutlen=20
              set <M-a>=^[a " where ^[a is produced via CTRL-v followed by a
              noremap <M-a> :Explore<CR>

              Does this really not work for others? I use it heavily on many linux systems
              with an unmodified termcap. It works on Redhat, Slackware and Archlinux that
              I know of. I am interested in knowing if I have done something by side effect
              to all of my systems without knowing it that allows this to work.



              Quoting "Charles E. Campbell" <cec@...>:

              > On Thu, Oct 31, 2002 at 07:04:01PM -0500, jproctor@... wrote:
              > >
              > > How does mapping Ctrl-V Ctrl-V Ctrl-V Alt-A to <M-a> differ from using
              > > set <M-a> Ctrl-V Alt-a
              > >
              > > Using set prevents having to do it for map, imap, etc.
              > >
              > > Also, I had to add the following to my vimrc for meta keys to work well
              > since
              > > <M-j> in insert mode was sometimes interpredted as <Esc> j, or end insert
              > and
              > > move down a line.
              > >
              > > set notimeout
              > > set ttimeout
              > > set ttimeoutlen=20
              > >
              > > Is your way better?
              > ---------------------------------------------------------------------
              >
              > Looks like I'm still learning about vim! However, your example didn't
              > work. In fact, a number of things I tried didn't work, but here's
              > one that finally did:
              >
              > :exe "set <m-a>=\<esc>[087q"
              >
              > Ones that don't work:
              >
              > :set <m-a>=<esc>[087q
              > :set <m-a>=
              > :set <m-a>=
              > :set <m-a>=
              > :set <m-a>="<esc>[087q"
              > :set <m-a>="\<esc>[087q"
              > :set <m-a>=""
              > :set <m-a>=""
              > :set <m-a>=""
              >
              > Anyway, I'd say the set method is better, but it isn't obvious how
              > to get it to work.
              >
              > Regards,
              > C Campbell
              >
              > --
              > Charles E Campbell, Jr, PhD _ __ __
              > Goddard Space Flight Center / /_/\_\_/ /
              > cec@... /_/ \/_//_/
              > PGP public key: http://www.erols.com/astronaut/pgp.html
              >
              >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.