2

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 
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. Commented Aug 12, 2015 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? Commented Aug 12, 2015 at 6:28
  • @Joseph I tried with space and direct enter both, give same behaviour Commented Aug 12, 2015 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 Commented Oct 7, 2019 at 17:08

1 Answer 1

2

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.

1
  • iab --> perfectly worked :) Commented Aug 12, 2015 at 14:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.