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

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

Expand Messages
  • Charles E. Campbell
    ... Here s a workaround: map ... etc where ... stands for press ctrl-v press ctrl-v press ctrl-v press alt-a and repeat for all alt keys that you
    Message 1 of 13 , Oct 31, 2002
    • 0 Attachment
      On Thu, Oct 31, 2002 at 05:55:19PM -0500, Arker wrote:
      > I've only been using Vim for a short while now (about a week) and everything
      > seems to be going quite well. The only problem I'm having is that the
      > <M-anything> binds will not work for me. I've downloaded some nice vim
      > scripts like auctex and a few others and they require these to work.
      ---------------------------------------------------------------------

      Here's a workaround:

      map ... <M-A> etc

      where ... stands for press ctrl-v
      press ctrl-v
      press ctrl-v
      press alt-a

      and repeat for all alt keys that you want to work. What this does is
      interpret your alt-key output into what vim is (erroneously) expecting.
      If you want to use imaps, too, you'll want to yank the entire set
      of lines you've laboriously produced, put down a new copy, and
      :...s/map/imap/ (where ... is the range of lines of the copy).

      Regards,
      C Campbell

      --
      Charles E Campbell, Jr, PhD _ __ __
      Goddard Space Flight Center / /_/\_\_/ /
      cec@... /_/ \/_//_/
      PGP public key: http://www.erols.com/astronaut/pgp.html
    • Arker
      Hey all, I ve only been using Vim for a short while now (about a week) and everything seems to be going quite well. The only problem I m having is that the
      Message 2 of 13 , Oct 31, 2002
      • 0 Attachment
        Hey all,

        I've only been using Vim for a short while now (about a week) and everything
        seems to be going quite well. The only problem I'm having is that the
        <M-anything> binds will not work for me. I've downloaded some nice vim
        scripts like auctex and a few others and they require these to work.

        Even without any scripts loaded, if I try to map something to a Meta/Alt
        bind, it will not work so I am wondering if there is some obscure setting that
        I need to set or that I have inadvertantly set that is messing me up.

        I'm using Gentoo Linux and vimming in aterm and gnome-terminal and a regular
        old PC keyboard with no Meta keys (just Alt). They do not work in gvim
        either.

        I must be missing something....

        Cheers,
        Arker
      • jproctor@prium.net
        How does mapping Ctrl-V Ctrl-V Ctrl-V Alt-A to differ from using set Ctrl-V Alt-a Using set prevents having to do it for map, imap, etc. Also, I
        Message 3 of 13 , Oct 31, 2002
        • 0 Attachment
          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?

          Thanks.


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

          > On Thu, Oct 31, 2002 at 05:55:19PM -0500, Arker wrote:
          > > I've only been using Vim for a short while now (about a week) and
          > everything
          > > seems to be going quite well. The only problem I'm having is that the
          > > <M-anything> binds will not work for me. I've downloaded some nice vim
          > > scripts like auctex and a few others and they require these to work.
          > ---------------------------------------------------------------------
          >
          > Here's a workaround:
          >
          > map ... <M-A> etc
          >
          > where ... stands for press ctrl-v
          > press ctrl-v
          > press ctrl-v
          > press alt-a
          >
          > and repeat for all alt keys that you want to work. What this does is
          > interpret your alt-key output into what vim is (erroneously) expecting.
          > If you want to use imaps, too, you'll want to yank the entire set
          > of lines you've laboriously produced, put down a new copy, and
          > :...s/map/imap/ (where ... is the range of lines of the copy).
          >
          > Regards,
          > C Campbell
          >
          > --
          > Charles E Campbell, Jr, PhD _ __ __
          > Goddard Space Flight Center / /_/\_\_/ /
          > cec@... /_/ \/_//_/
          > PGP public key: http://www.erols.com/astronaut/pgp.html
          >
          >
          >
        • Michael Geddes
          I have this problem when I use Win32 with encoding=utf-8 .. //. ... From: Arker [mailto:arker@rogers.com] Sent: Friday, 1 November 2002 11:18 AM To: Charles
          Message 4 of 13 , Oct 31, 2002
          • 0 Attachment
            I have this problem when I use Win32 with encoding=utf-8 ..

            //.

            -----Original Message-----
            From: Arker [mailto:arker@...]
            Sent: Friday, 1 November 2002 11:18 AM
            To: Charles E. Campbell; vim@...
            Subject: Re: [vim] Friggin' Alt Keys...


            On October 31, 2002 05:34 pm, Charles E. Campbell wrote:
            > On Thu, Oct 31, 2002 at 05:55:19PM -0500, Arker wrote:
            > > I've only been using Vim for a short while now (about a week) and
            > > everything seems to be going quite well. The only problem I'm having

            > > is that the <M-anything> binds will not work for me. I've downloaded

            > > some nice vim scripts like auctex and a few others and they require
            > > these to work.
            >
            > ---------------------------------------------------------------------
            >
            > Here's a workaround:
            >
            > map ... <M-A> etc
            >
            > where ... stands for press ctrl-v
            > press ctrl-v
            > press ctrl-v
            > press alt-a
            >
            > and repeat for all alt keys that you want to work. What this does is
            > interpret your alt-key output into what vim is (erroneously)
            > expecting. If you want to use imaps, too, you'll want to yank the
            > entire set of lines you've laboriously produced, put down a new copy,
            > and
            >
            > :...s/map/imap/ (where ... is the range of lines of the copy).
            >
            > Regards,
            > C Campbell

            That actually works! Thanks for the help...

            But now I'm curious, what is the problem with my machine? Is this a
            common problem for Vim users? It seems alot of scripts use these types
            of binds but I've seen no mention of the workaround you suggest in
            either the script docs or the Vim docs.

            Seems odd that this is a popular issue, yet at the same time, you had a
            fairly quick workaround, so it cannot be unheard of.

            Could you please enlighten me?

            Thanks again!
            Arker
          • Arker
            ... That actually works! Thanks for the help... But now I m curious, what is the problem with my machine? Is this a common problem for Vim users? It seems alot
            Message 5 of 13 , Oct 31, 2002
            • 0 Attachment
              On October 31, 2002 05:34 pm, Charles E. Campbell wrote:
              > On Thu, Oct 31, 2002 at 05:55:19PM -0500, Arker wrote:
              > > I've only been using Vim for a short while now (about a week) and
              > > everything seems to be going quite well. The only problem I'm having is
              > > that the <M-anything> binds will not work for me. I've downloaded some
              > > nice vim scripts like auctex and a few others and they require these to
              > > work.
              >
              > ---------------------------------------------------------------------
              >
              > Here's a workaround:
              >
              > map ... <M-A> etc
              >
              > where ... stands for press ctrl-v
              > press ctrl-v
              > press ctrl-v
              > press alt-a
              >
              > and repeat for all alt keys that you want to work. What this does is
              > interpret your alt-key output into what vim is (erroneously) expecting.
              > If you want to use imaps, too, you'll want to yank the entire set
              > of lines you've laboriously produced, put down a new copy, and
              >
              > :...s/map/imap/ (where ... is the range of lines of the copy).
              >
              > Regards,
              > C Campbell

              That actually works! Thanks for the help...

              But now I'm curious, what is the problem with my machine? Is this a
              common problem for Vim users? It seems alot of scripts use these types
              of binds but I've seen no mention of the workaround you suggest in
              either the script docs or the Vim docs.

              Seems odd that this is a popular issue, yet at the same time, you had a
              fairly quick workaround, so it cannot be unheard of.

              Could you please enlighten me?

              Thanks again!
              Arker
            • Antoine J. Mechelynck
              ... [...] If you change the encoding setting to something different than what your keyboard types, you must also change termencoding ; for instance if
              Message 6 of 13 , Oct 31, 2002
              • 0 Attachment
                Michael Geddes <mgeddes@...> wrote:
                > I have this problem when I use Win32 with encoding=utf-8 ..
                [...]

                If you change the 'encoding' setting to something different than what your
                keyboard types, you must also change 'termencoding'; for instance

                if has("multi_byte")
                let &termencoding = &encoding
                set encoding=utf-8
                set fileencodings=ucs-bom,ISO-8859-15,utf-8
                else
                echoerr("This version of vim does not support Unicode")
                endif

                see the FAQ entry at
                http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#34.1 and following,
                and my tip http://vim.sourceforge.net/tip_view.php?tip_id=246

                HTH,
                Tony.
              • Arker
                ... Doh! Problem with this seems to be that now when I do something like leaving Insert mode by way of the key, if the first thing I try to do is move
                Message 7 of 13 , Nov 1, 2002
                • 0 Attachment
                  On October 31, 2002 05:34 pm, Charles E. Campbell wrote:
                  >
                  > Here's a workaround:
                  >
                  > map ... <M-A> etc
                  >
                  > where ... stands for press ctrl-v
                  > press ctrl-v
                  > press ctrl-v
                  > press alt-a

                  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?

                  Arker
                • Arker
                  ... One difference is that when I use the set Ctrl-V Alt-a method, I get an error when loading the .vimrc that says: Unknown option: So, at least
                  Message 8 of 13 , Nov 1, 2002
                  • 0 Attachment
                    On October 31, 2002 07:04 pm, 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

                    One difference is that when I use the 'set <M-a> Ctrl-V Alt-a' method, I
                    get an error when loading the .vimrc that says:

                    Unknown option: <M-a>

                    So, at least here, that method will not work at all. There must be a
                    reason why the alt key is not working. I just need to find the magic
                    setting? ;-)

                    Arker
                  • 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 9 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 10 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 11 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 12 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 13 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.