-- 有没有办法复制搜索词,包括该词?
如果我有以下单词
cat Oliver Louis
并且光标位于“c”上,我可以使用 y/Louis
复制到 Louis 的开头(其中“CR”是回车键),这将复制字符串“cat Oliver”。
有没有办法复制搜索词“Louis”,以及复制的“cat Oliver Louis”字符串?提前致谢。
If I have the following words
cat Oliver Louis
and the cursor is on "c", I can copy up to the beginning of Louis with y/Louis<CR>
(where "CR" is the enter key), which will copy the string "cat Oliver ".
Is there a way to copy the search term, "Louis", as well, for a copied string of "cat Oliver Louis"? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
/e
修饰符:y/Louis/e
。如果您想重复上一个搜索模式,只需将其省略:y//e
。Use the
/e
modifier:y/Louis/e<CR>
. If you want to repeat the last search pattern, just leave it out:y//e<CR>
.由于
/
搜索是独占,因此它将选择匹配项之前的所有内容,但不包括匹配项。 (检查:help Exclusive
)更方便的方法可能是使用 inclusive
f
和t
运动命令。使用以下行:
在正常模式下输入
yfs
会将所有内容猛拉到字母“s”,或者在本例中为cat Oliver Louis
显然,这并不像如果该行类似于
There are too much s's,那就很方便了。在这种情况下,您可能想要进入视觉模式,并通过点击
;
重复包含f
搜索动作,直到到达最后一个 s。或者,正如您上面所建议的,只需使用w
前面加上您要复制的字数。在这种情况下,y3w
将起作用。Since the
/
search is exclusive, it will select everything up to the match, but not including the match. (check:help exclusive
)A more convenient way might be to use the inclusive
f
andt
motion commands.With the following line:
typing
yfs
in normal mode will yank everything up to the letter "s", or in this case,cat Oliver Louis
Obviously, this isn't as convenient if the line is something like
There are too many s's. In this case you might want to go into visual mode and either repeat the inclusive
f
search motion by tapping;
until you reach the last s. Or, as you suggested above, simply usew
preceded by the number of words you'd like to copy. In this casey3w
will work.一种方法是使用后视断言...但语法相当难看!
这不会查找 Louis,而是查找前面带有字符串 Louis 的位置。
One way is to use look-behind assertions... but the syntax is rather ugly!
This doesn't look for Louis, but for a position preceded by the string Louis.