在VIM的下一场比赛后,我如何跳到?
我有一个文件,我正在工作,我需要做很多编辑。在我需要编辑的内容之前的文本是恒定的,但我需要编辑的内容是不同的。我现在正在做的是在VIM的下一场比赛后,我如何跳到?,vim,Vim,我有一个文件,我正在工作,我需要做很多编辑。在我需要编辑的内容之前的文本是恒定的,但我需要编辑的内容是不同的。我现在正在做的是 /my\u constant\u text和n跳转到需要编辑的行。但是像这样使用n,我仍然需要将光标向前移动到匹配的文本之后,才能到达我想要开始编辑的位置。在我看来,必须有一种方法让光标刚好经过匹配的文本,但我没有找到它 如果有帮助的话,我正在处理的文件看起来就像下面两行重复了很多次,只是值不同 INSERT INTO TABLE (ID, NAME, VALUE) V
/my\u constant\u text
和n
跳转到需要编辑的行。但是像这样使用n
,我仍然需要将光标向前移动到匹配的文本之后,才能到达我想要开始编辑的位置。在我看来,必须有一种方法让光标刚好经过匹配的文本,但我没有找到它
如果有帮助的话,我正在处理的文件看起来就像下面两行重复了很多次,只是值不同
INSERT INTO TABLE (ID, NAME, VALUE) VALUES ('1','foo','all sorts of random stuff')
INSERT INTO TABLE (ID, NAME, VALUE) VALUES ('2','bar','some other random stuff')
我希望能够将光标跳转到“foo”之后。(即我的常量文本)。使用
/constant\u text/e
跳转到常量文本的末尾,或者使用/constant\u text/e+1
跳转到常量文本之后。正如Jan所说,使用“/e”修饰符。如果它比搜索字符串更复杂,那么总是有宏
qanf,q
要将宏nf,
(这将是您的复杂内容,而不仅仅是nf,
)存储在宏a
,然后
@a
称之为。事物可以更通用{offset}
+这很有道理,但我从没想过。我又学到了一些新的东西,thx。显然这叫做搜索偏移量,:help offset你也可以://e+3,://e-1,://b+1等等
[...] With "/" and "?" an
additional offset may be given. There are two types of offsets: line offsets
and character offsets. {the character offsets are not in Vi}
The offset gives the cursor position relative to the found match:
[num] [num] lines downwards, in column 1
+[num] [num] lines downwards, in column 1
-[num] [num] lines upwards, in column 1
e[+num] [num] characters to the right of the end of the match
e[-num] [num] characters to the left of the end of the match
s[+num] [num] characters to the right of the start of the match
s[-num] [num] characters to the left of the start of the match
b[+num] [num] identical to s[+num] above (mnemonic: begin)
b[-num] [num] identical to s[-num] above (mnemonic: begin)
;{pattern} perform another search, see |//;|