是否可以使用命令ab在vim中缩写两个单词

时间:2014-12-26 22:26:22

标签: vim command vi ex

我的问题很简单:有没有办法只使用ab中的 vi 命令缩短由空格分隔的两个单词。 ..有可能逃脱太空人物吗?

在stackoverflow中,我发现只有one,但所有答案都是使用替换命令。我也尝试过:

:ab word1<space>word2 replaceWord

但徒劳(产生错误)

2 个答案:

答案 0 :(得分:3)

不幸的是,这是不可能的。

来自:help :abbreviate

Examples of strings that cannot be abbreviations: "a.b", "#def", "a b", "_$r"

那是因为只有三种类型的缩写(仍来自:help):

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$"

答案 1 :(得分:2)

实际上它可以被模仿。

您必须在word2上定义一个缩写,以便检查它之前的内容。我做了详细的answer about having abbreviation starting with '\',它是一样的(除了你可能要测试前一行的最后一个字)。