-- 有没有办法复制搜索词,包括该词?

发布于 2024-09-10 09:20:21 字数 219 浏览 2 评论 0原文

如果我有以下单词

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心的位置 2024-09-17 09:20:21

使用 /e 修饰符:y/Louis/e。如果您想重复上一个搜索模式,只需将其省略:y//e

:help search-offset

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 search-offset
指尖上的星空 2024-09-17 09:20:21

由于 / 搜索是独占,因此它将选择匹配项之前的所有内容,但不包括匹配项。 (检查 :help Exclusive

更方便的方法可能是使用 inclusive ft 运动命令。

使用以下行:

cat Oliver Louis

在正常模式下输入 yfs 会将所有内容猛拉到字母“s”,或者在本例中为 cat Oliver Louis

显然,这并不像如果该行类似于

cat Assassins Scissors

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 and t motion commands.

With the following line:

cat Oliver Louis

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

cat Assassins Scissors

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 use w preceded by the number of words you'd like to copy. In this case y3w will work.

纸短情长 2024-09-17 09:20:21

一种方法是使用后视断言...但语法相当难看!

y/\(Louis\)\@<=

这不会查找 Louis,而是查找前面带有字符串 Louis 的位置。

One way is to use look-behind assertions... but the syntax is rather ugly!

y/\(Louis\)\@<=

This doesn't look for Louis, but for a position preceded by the string Louis.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文