I have abbreviated main to '#include.....', I was looking to unabbreviate it for one vim session, and tried the following

:una main

I get error 'E24: No such abbreviation'. The problem is, it's expanding the main in this command also. When I check the history, it shows

:una #include<stdio.h>

which proves that it has expanded the abbreviation.

I hope it's clear. Is there any way to solve this issue? I know abc will clear all abbreviations, but I am only looking to unabbreviate one abbreviation.

I am using this version:

$ vim --version
VIM - Vi IMproved 7.4 
  • I have the same vim version and I can't reproduce this behavior. My command history shows (like yours) that the abbreviation was expanded with una but it is disabled after I enter the command. – Joseph R. Aug 12 '15 at 6:21
  • Could it be that you're typing :una main followed by a space? In other words, are you causing the abbreviation to be expanded before entering the command? – Joseph R. Aug 12 '15 at 6:28
  • @Joseph I tried with space and direct enter both, give same behaviour – mtk Aug 12 '15 at 13:57
  • Also note, if you abbreviate at the buffer level, you have to unabbreviate at the buffer level as well, e.g. iuna <buffer> main – jeberle Oct 7 at 17:08

You can insert CTRL-V somewhere in the abbreviation to avoid the abbreviation occur. After typing :una ma, press Ctrl+v twice, then typ in, your command mode now look like this:

:una ma^Vin

Press Enter and the abbreviation was gone.

It's better if you only define abbreviation in which mode you want to operate. In your case, using iab to make main only work in insert mode. You won't face the same problem when you un-abbreviate it in command mode.

  • iab --> perfectly worked :) – mtk Aug 12 '15 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.