有没有一种搜索模式的方法,但是当存在匹配项时,将光标放在模式的末尾而不是开头?
例如,/ my ENTER会将光标置于'myvariable'('m')的开头。
我经常发现,如果将光标放置在搜索模式的结尾之后(这里,在“ v”上),这将很方便。这可能吗 ?
从中:help /可以看到/{pattern}/{offset}<CR>模式。
来自:help offset:
*search-offset* *{offset}*
These commands search for the specified pattern. With "/" and "?" an
additional offset may be given. There are two types of offsets: line offsets
and character offsets.
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 ## This is the one you want
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 |//;|
If a '-' or '+' is given but [num] is omitted, a count of one will be used.
When including an offset with 'e', the search becomes inclusive (the
character the cursor lands on is included in operations).
Run Code Online (Sandbox Code Playgroud)
所以你的情况使用/my/e+(或/my/e+1)土地上v的myvariable。