加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – 如何在vim中解释“:%g // t $”?

发布时间:2020-12-14 05:36:04 所属栏目:百科 来源:网络整理
导读:我找到了这个 :%g/h[12]/ t$ 在http://www.vimregex.com/ 它说 This command searches our file for the lines starting with h1 or h2 and copies them to the end of the file. 但我无法理解部分/ t $,这是什么意思? 解决方法 如果在vim中运行此帮助命令
我找到了这个

:%g/<h[12]>/ t$

在http://www.vimregex.com/

它说

This command searches our file for the lines starting with <h1> or
<h2> and copies them to the end of the file.

但我无法理解部分/ t $,这是什么意思?

解决方法

如果在vim中运行此帮助命令:

:help copy

它将显示以下可以解释所有内容的帮助:

:[range]co[py] {address}                *:co* *:copy*
            Copy the lines given by [range] to below the line
            given by {address}.

                            *:t*
:t          Synonym for copy.

详细信息:

>:g:全局搜索
>< h [12]>:搜索< h1>或者< h2>
> t $或copy $:将[range]给出的行复制到{address}给出的行以下.

你可以把它变得更加冗长.但使用此等效命令更具可读性:

:%g/<h[12]>/ copy$

或这个:

:%g/<h[12]>/ co$

要在文件中复制匹配行,请使用:

:%g/<h[12]>/ copy0

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读