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

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

Expand Messages
  • 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 1 of 2 , Mar 14, 2009
    • 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.