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

Avoiding expansion of command-line abbreviations

Expand Messages
  • Ben Fritz
    ... Experience has shown me that the second insert mode method (press CTRL- V just before the character after the abbreviation) also works in command-line
    Message 1 of 1 , Jun 1, 2009
    • 0 Attachment
      The help (just above :help :abbreviate-local) says:

      > To avoid the abbreviation in insert mode: Type part of the abbreviation, exit
      > insert mode with <Esc>, re-enter insert mode with "a" and type the rest. Or
      > type CTRL-V before the character after the abbreviation.
      > To avoid the abbreviation in Command-line mode: Type CTRL-V twice somewhere in
      > the abbreviation to avoid it to be replaced. A CTRL-V in front of a normal
      > character is mostly ignored otherwise.

      Experience has shown me that the second insert mode method (press CTRL-
      V just before the character after the abbreviation) also works in
      command-line mode. For example, I have a cabbrev of q!@ to just q! (a
      common typo of mine). Typing q!@<C-V><Space> works just fine to avoid
      expansion of the abbreviation. Pressing q!<C-V><C-V>@<Space> on the
      other hand does avoids the abbreviation, but also inserts a ^V
      character in the command. I can certainly see this causing problems,
      especially if you're entering not an ex command, but a search, where
      the ^V will not be ignored but will rather be included in the search.

      In addition, the given method sometimes causes an ex command to be
      invalid. For example, I have a cabbrev for "vimgrep" that will expand
      to a "noautocmd vimgrep" for the word under the cursor. Entering vim<C-
      V><C-V>grep /pattern/ *.txt gives "E682: Invalid search pattern or
      delimiter" whereas vimgrep<C-V> /pattern/ *.txt acts as desired.

      Is there some reason the <C-V><C-V> would ever be desirable in command-
      line mode over the second method listed for insert mode? I have yet to
      find a situation where it is better, but I figure there must be some
      reason this is the suggested method.
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.