如何转义 vim 缩写中的字符?
How do I escape characters in a vim abbreviation?
我正在尝试在我的 Vimrc 中使用这个缩写进行降价编辑:
iabbrev ,,img ![<alt-text>](<img-link>)
我认为此处的括号需要转义,但我不确定如何在不在缩写中包含转义字符的情况下转义这些字符。
我该怎么办?
在我尝试重现你的问题时,我发现 vim 给我一个错误,因为你的缩写 ,,img
.[=] 的 left-hand 边有两个逗号。 14=]
这些对我有用:
iabbrev img ![<alt-text>](<img-link>)
iabbrev __img ![<alt-text>](<img-link>)
同时:
iabbrev ,,img ![<alt-text>](<img-link>)
给我错误:
E474: Invalid argument
缩写形式如下(参见: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-keyword 个字符。也不可以是non-id
。
我建议您更改缩写。例如img,,
我正在尝试在我的 Vimrc 中使用这个缩写进行降价编辑:
iabbrev ,,img ![<alt-text>](<img-link>)
我认为此处的括号需要转义,但我不确定如何在不在缩写中包含转义字符的情况下转义这些字符。
我该怎么办?
在我尝试重现你的问题时,我发现 vim 给我一个错误,因为你的缩写 ,,img
.[=] 的 left-hand 边有两个逗号。 14=]
这些对我有用:
iabbrev img ![<alt-text>](<img-link>)
iabbrev __img ![<alt-text>](<img-link>)
同时:
iabbrev ,,img ![<alt-text>](<img-link>)
给我错误:
E474: Invalid argument
缩写形式如下(参见: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-keyword 个字符。也不可以是non-id
。
我建议您更改缩写。例如img,,