如何在vim缩写中转义字符?

时间:2019-06-05 19:23:15

标签: vim vim-plugin

我正在尝试在我的Vimrc中对此标记进行降价编辑:
iabbrev ,,img ![<alt-text>](<img-link>)

我认为这里需要对括号进行转义,但是我不确定如何在不将转义字符也包含在缩写中的情况下对这些字符进行转义。
我该怎么办?

2 个答案:

答案 0 :(得分:3)

缩写有以下几种形式(请参见:h abbreviations):

There are three types of abbreviations:

full-id   The "full-id" type consists entirely of keyword characters (letters
      and characters from 'iskeyword' option).  This is the most common
      abbreviation.

      Examples: "foo", "g3", "-1"

end-id    The "end-id" type ends in a keyword character, but all the other
      characters are not keyword characters.

      Examples: "#i", "..f", "$/7"

non-id    The "non-id" type ends in a non-keyword character, the other
      characters may be of any type, excluding space and tab.  {this type
      is not supported by Vi}

      Examples: "def#", "4/7$"

,,img不能是full-id,因为它以,开头。不能为end-id,因为所有其他字符都必须为非关键字字符。也不能是non-id

我建议更改您的缩写。例如img,,

答案 1 :(得分:1)

在尝试重现您的问题时,我发现由于缩写,,img左侧的两个逗号,vim给我一个错误。

这些对我有用:

iabbrev img ![<alt-text>](<img-link>)
iabbrev __img ![<alt-text>](<img-link>)

与此同时:

iabbrev ,,img ![<alt-text>](<img-link>)

给我错误:

  

E474:无效的参数