如何在 Vim 中选择一行的一部分
我有一行文本,看起来像这样,
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在行首时,
将拉取 URL 部分而不更改光标位置。
如果你想作为命令
执行同样的操作。
While on the beginning of a line,
will yank the URL part while not changing the cursor position.
If you want to do it as a command
does the same thing.
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.如果我在不同的行上,我会使用
/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).其中 ^v = Ctrl + v 和 ^m = Enter
Where ^v = Ctrl + v and ^m = Enter