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

Re: mapping broken

Expand Messages
  • Ben Schmidt
    ... This is to be expected. The codes that console Vim is sent by the terminal program tend not to be distinct for keys with and without modifiers, so Vim has
    Message 1 of 17 , Feb 3, 2008
    • 0 Attachment
      > The problem: that mapping only works in MacVim and x11 gvim; it does not work in console vim, either in Terminal.app, xterm, or rxvt.

      This is to be expected. The codes that console Vim is sent by the terminal program
      tend not to be distinct for keys with and without modifiers, so Vim has no way of
      telling the difference. But there are some exceptions...

      > In console vim, I keep getting "E29" and something about not having selected anything to paste. When that doesn't happen, vim will bizarrely paste things in.

      So, evidently Vim is receiving 'something'...You can probably find out what it is
      by using Ctrl-V. Say, enter ':map ' (including that space) then press Ctrl-V then
      press Ctrl-Space. The Ctrl-V makes Vim enter what it receives into the command
      rather than acting on it, so you should be able to see/use what the Ctrl-Space
      produces.

      > Any ideas? Thanks!

      Another option is to try to get your terminal program to do the mapping...i.e. to
      send something special to Vim for Ctrl-Space (or even just Esc!) and then get Vim
      to act on that. In Terminal.app the facility for doing this sort of thing can be
      found by doing File, Show Info, Keyboard (in the popup menu at the top of the
      window that appears), but it doesn't allow you to set it for any key, only a
      handful of keys it has preselected, and Space isn't one of them unfortunately.

      It can quite possibly be done by some option in one of your X configuration files
      which would work in xterm. Probably the folk on vim_use would have more idea about
      that than the vim_mac guys, so maybe try asking there.

      Cheers,

      Ben.




      Send instant messages to your online friends http://au.messenger.yahoo.com


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • dv1445@wayne.edu
      ... I did this as prescribed, and vim shows me this: ^@ What does that mean? I did h: @ and it looks like the @ sign has something to do with registers, which
      Message 2 of 17 , Feb 3, 2008
      • 0 Attachment
        Thus spake Ben Schmidt [02/04/08 @ 14.21.34 +1100]:
        > > The problem: that mapping only works in MacVim and x11 gvim; it does not work in console vim, either in Terminal.app, xterm, or rxvt.
        >
        > This is to be expected. The codes that console Vim is sent by the terminal program
        > tend not to be distinct for keys with and without modifiers, so Vim has no way of
        > telling the difference. But there are some exceptions...
        >
        > > In console vim, I keep getting "E29" and something about not having selected anything to paste. When that doesn't happen, vim will bizarrely paste things in.
        >
        > So, evidently Vim is receiving 'something'...You can probably find out what it is
        > by using Ctrl-V. Say, enter ':map ' (including that space) then press Ctrl-V then
        > press Ctrl-Space. The Ctrl-V makes Vim enter what it receives into the command
        > rather than acting on it, so you should be able to see/use what the Ctrl-Space
        > produces.

        I did this as prescribed, and vim shows me this: ^@

        What does that mean? I did h: @ and it looks like the @ sign has something to do with registers, which would explain the bizarre, occasional pasting that vim does when I hit <C-Space>. How can I get vim to stop seeing <Ctrl-Space> as ^@?

        Thanks much.
        -GMN

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Ben Schmidt
        ... ^@ means ctrl-@, and at :help i_CTRL-@ we find what this ordinarily does: Insert previously inserted text and stop insert. So that definitely explains
        Message 3 of 17 , Feb 3, 2008
        • 0 Attachment
          > I did this as prescribed, and vim shows me this: ^@
          >
          > What does that mean?

          ^@ means ctrl-@, and at :help i_CTRL-@ we find what this ordinarily does: "Insert
          previously inserted text and stop insert." So that definitely explains the
          behaviour you're getting.

          > How can I get vim to stop seeing <Ctrl-Space> as ^@?

          It would have to be a terminal option or something for the program you are using.

          But do you need to? Could you just map <C-@> instead? I.e. since Vim thinks you're
          pressing ctrl-@, just map ctrl-@ to what you wanted to map ctrl-space to! As far
          as I can tell, this would only be a problem if you actually wanted to use ctrl-@
          for something different to ctrl-space.

          Cheers,

          Ben.


          Send instant messages to your online friends http://au.messenger.yahoo.com


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • dv1445@wayne.edu
          ... Oy vey, I should have known that ^@ was Ctrl-@. Sorry for the wasted space. ... Thanks for the help and suggestion! I tried this after reading your tip
          Message 4 of 17 , Feb 4, 2008
          • 0 Attachment
            Thus spake Ben Schmidt [02/04/08 @ 15.08.13 +1100]:
            > ^@ means ctrl-@, and at :help i_CTRL-@ we find what this ordinarily does: "Insert
            > previously inserted text and stop insert." So that definitely explains the
            > behaviour you're getting.

            Oy vey, I should have known that ^@ was Ctrl-@. Sorry for the wasted space.

            > But do you need to? Could you just map <C-@> instead? I.e. since Vim thinks you're
            > pressing ctrl-@, just map ctrl-@ to what you wanted to map ctrl-space to! As far
            > as I can tell, this would only be a problem if you actually wanted to use ctrl-@
            > for something different to ctrl-space.

            Thanks for the help and suggestion! I tried this after reading your tip but it didn't work. Terminal.app still sees <C-space> as the command that <C-@> normally calls, namely, paste the last inserted.

            Thanks again, this was informative. Now I can concentrate on finding something else to map to <esc> for when I'm in console vim.
            -GMN

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Ben Schmidt
            ... I just tried it myself and it works for me. Did you use the right kind of mapping for the mode you re trying to use it in? I.e. you probably want both map
            Message 5 of 17 , Feb 4, 2008
            • 0 Attachment
              > Thanks for the help and suggestion! I tried this after reading your tip but it didn't work. Terminal.app still sees <C-space> as the command that <C-@> normally calls, namely, paste the last inserted.

              I just tried it myself and it works for me.

              Did you use the right kind of mapping for the mode you're trying to use it in?
              I.e. you probably want both

              map <C-@> <Esc>

              and

              map! <C-@> <Esc>

              Cheers,

              Ben.



              Send instant messages to your online friends http://au.messenger.yahoo.com


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • dv1445@wayne.edu
              ... Hey, that worked! I didn t do `map! before. This time I did both map and map!, with the right result. Question: do I need to do both :map
              Message 6 of 17 , Feb 4, 2008
              • 0 Attachment
                Thus spake Ben Schmidt [02/05/08 @ 01.23.50 +1100]:
                > > Thanks for the help and suggestion! I tried this after reading your tip but it didn't work. Terminal.app still sees <C-space> as the command that <C-@> normally calls, namely, paste the last inserted.
                >
                > I just tried it myself and it works for me.
                >
                > Did you use the right kind of mapping for the mode you're trying to use it in?
                > I.e. you probably want both
                >
                > map <C-@> <Esc>
                >
                > and
                >
                > map! <C-@> <Esc>

                Hey, that worked! I didn't do `map!' before. This time I did both map and map!, with the right result.

                Question: do I need to do both :map <Ctrl-Space> and :map! <Ctrl-Space>? I only tested your tip a couple of times, but maybe to get it right in all contexts I need the exclamation point.

                Thanks much. This makes me able to avoid <Esc>.

                -GMN

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_mac" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • dv1445@wayne.edu
                ... Whoops, I may have spoken too soon when I said this works. It appears to work for console vim, but it threw MacVim off kilter. It used to work in MacVim
                Message 7 of 17 , Feb 4, 2008
                • 0 Attachment
                  Thus spake Ben Schmidt [02/05/08 @ 01.23.50 +1100]:
                  > I just tried it myself and it works for me.
                  >
                  > Did you use the right kind of mapping for the mode you're trying to use it in?
                  > I.e. you probably want both
                  >
                  > map <C-@> <Esc>
                  >
                  > and
                  >
                  > map! <C-@> <Esc>

                  Whoops, I may have spoken too soon when I said this works. It appears to work for console vim, but it threw MacVim off kilter. It used to work in MacVim but not console, and now it's the reverse. <C-Space> does what <C-@> really does, paste last inserted, despite my mapping <C-@> to <Esc> in the .vimrc.

                  First I thought maybe I have to do it in .gvimrc too, but clearly MacVim picks up on my mappings in .vimrc.

                  -GMN

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_mac" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Ben Schmidt
                  ... explains them. ... Yes. .vimrc is always used. .gvimrc is used in addition when the GUI is started. More (much) more info, you can check out ... To handle
                  Message 8 of 17 , Feb 4, 2008
                  • 0 Attachment
                    >> map <C-@> <Esc>
                    >> map! <C-@> <Esc>

                    :map is for normal mode, visual mode, some others.
                    :map! is for insert mode, commandline mode, some others.

                    :help map-modes

                    explains them.

                    > Whoops, I may have spoken too soon when I said this works. It appears to work for console vim, but it threw MacVim off kilter. It used to work in MacVim but not console, and now it's the reverse. <C-Space> does what <C-@> really does, paste last inserted, despite my mapping <C-@> to <Esc> in the .vimrc.
                    >
                    > First I thought maybe I have to do it in .gvimrc too, but clearly MacVim picks up on my mappings in .vimrc.

                    Yes. .vimrc is always used. .gvimrc is used in addition when the GUI is started.
                    More (much) more info, you can check out

                    :help vimrc
                    :help gvimrc

                    To handle both cases, maybe you need to do something a bit more fancy in your
                    .vimrc like

                    if has('gui_running')
                    map <C-Space> <Esc>
                    map! <C-Space> <Esc>
                    else
                    map <C-@> <Esc>
                    map! <C-@> <Esc>
                    endif

                    Or leave the .vimrc like you had it, but unmap and map again in your .gvimrc:

                    unmap <C-@>
                    unmap! <C-@>
                    map <C-Space> <Esc>
                    map! <C-Space> <Esc>

                    Ben.



                    Send instant messages to your online friends http://au.messenger.yahoo.com


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_mac" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.