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

Re: mapping broken

Expand Messages
  • 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 1 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 2 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 3 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 4 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 5 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 6 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.