On 11/06/11 16:51, Quincy Bowers wrote:
I would like to create an abbreviation like the following:

     :iabbrev @author @author Author Name

But when I attempt this I get the error 'E474: Invalid argument'.

This works fine though:

     :iabbrev @ @author Author Name

I was going to say you were doing something wrong, but I messed with this for a good 10 minutes and was befuddled by the behavior.

Strangely, I noticed that if I'm in a help window and I execute your first command, it works fine for me:

  :help
  :iab @author @author Author Name
  :set modifiable
  (ignore warning about changing a read-only file)
  (insert "@author" in the text, and it expands as expected)

However, when I did it in a regular (non-help) text window, it errored for anything longer than ":iab @a @author Author Name", so if I try ":iab @au @author Author Name", it fails with the E474. If I try combinations of ":set buftype=help nomodifiable readonly" in a regular buffer to make it "help-ish", it also gives the E474 when I try the :iab

I finally tracked it down to the fact that help-windows change the 'iskeyword' setting:

  vi -u NONE
  :set isk?
  :help
  :set isk?

and compare the values. When I changed the setting for 'isk' to remove "@", I could successfully issue your initial mapping:

  :set isk-=@
  :iab @author @author Author Name

and it worked without error, both creating the mapping and expanding in insert mode.

I'm not sure why, regardless of the 'isk' setting, abbreviating "@a" worked, but not "@author".

Hope that helps work around what I think might be a bug,

-tim





--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to