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

":map! " mapping executes command, does not cancel

Expand Messages
  • Simo Salminen
    Hello. I have following bindings: map map! When I enter into command mode (:) and write foo , and press C-Space, it executes
    Message 1 of 2 , Mar 13 4:22 PM
    • 0 Attachment
      Hello.

      I have following bindings:
      map <C-Space> <Esc>
      map! <C-Space> <Esc>


      When I enter into command mode (:) and write "foo", and press C-Space,
      it executes command:
      E492: Not an editor command:foo

      So I'm wondering why it won't cancel it?

      Pressing <Esc> or using <C-c> cancels command mode normally. I
      verified this with plain vim settings (running
      without .vimrc/.gvimrc/.vim files), so my other settings/bindings do
      not cause this.

      The <C-Space> space works fine when exiting insert mode.

      My system is MacVim snapshot 43 on Tiger 10.4.11. Also verified with
      MacVim 7.2.


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • björn
      ... You have to map to instead of in command line mode: map! will do it. See :h c_ for some more info. There is some more
      Message 2 of 2 , Mar 14 7:23 AM
      • 0 Attachment
        2009/3/14 Simo Salminen:
        >
        > Hello.
        >
        > I have following bindings:
        >   map <C-Space> <Esc>
        >   map! <C-Space> <Esc>
        >
        >
        > When I enter into command mode (:) and write "foo", and press C-Space,
        > it executes command:
        > E492: Not an editor command:foo
        >
        > So I'm wondering why it won't cancel it?
        >
        > Pressing <Esc> or using <C-c> cancels command mode normally. I
        > verified this with plain vim settings (running
        > without .vimrc/.gvimrc/.vim files), so my other settings/bindings do
        > not cause this.
        >
        > The <C-Space> space works fine when exiting insert mode.

        You have to map to <C-c> instead of <Esc> in command line mode:

        map! <C-Space> <C-c>

        will do it. See ":h c_<Esc>" for some more info. There is some more
        info in this thread:

        http://www.nabble.com/remapping-different-keys-to-Escape-in-command-mode-doesn%27t-work-as-expected-td20428350.html

        Also, if you are in the process of finding an "Esc-replacement" then
        why not look into using Caps Lock as Esc? I have installed
        PCKeyboardHack which can be downloaded from here:

        http://www.pqrs.org/tekezo/macosx/keyremap4macbook/extra.html

        See ":h macvim|/caps lock" for more info on this.

        Björn

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