如何在 Vim 中选择一行的一部分

发布于 2024-12-17 06:22:53 字数 199 浏览 1 评论 0原文

我有一行文本,看起来像这样,

foo bar http://www.example.com -> baz

我想使用 ex 提取 url 部分。有人对如何做到这一点有任何想法吗?

澄清一下。我想从命令行执行类似 :y/http:.*\.com/ 的操作。但这是行不通的。

I have a line of text that looks like this

foo bar http://www.example.com -> baz

I want yank the url part using ex. Anyone have any ideas on how to do this?

To clarify. I want to do something like this :y/http:.*\.com/ from the command line. But that doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

枕梦 2024-12-24 06:22:53

在行首时,

wwviWy

将拉取 URL 部分而不更改光标位置。


如果你想作为命令

:execute "normal! wwviWy0"

执行同样的操作。

While on the beginning of a line,

wwviWy

will yank the URL part while not changing the cursor position.


If you want to do it as a command

:execute "normal! wwviWy0"

does the same thing.

我早已燃尽 2024-12-24 06:22:53

URL 符合 WORD 的定义,因此当光标位于开头时,可以使用 yW 来执行此操作。

The URL fits the definition of a WORD, so you can do it with yW when the cursor is at the beginning.

绝情姑娘 2024-12-24 06:22:53

如果我在不同的行上,我会使用 /http 来获取 URL 的开头,如果我在同一行,然后 yt (最后一个键是空格)。

I would use /http to get at the begining of the URL if I were on a different line, or fh if I were on the same line and then yt (last key is space).

鱼忆七猫命九 2024-12-24 06:22:53
normal /http^v^m^v^mv2fm <Enter>

其中 ^v = Ctrl + v 和 ^m = Enter

normal /http^v^m^v^mv2fm <Enter>

Where ^v = Ctrl + v and ^m = Enter

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