【问题标题】:How to substitute the below string using gvim %s command如何使用 gvim %s 命令替换下面的字符串
【发布时间】:2017-09-21 09:22:45
【问题描述】:

我想替换这个

disable iff (!(gth_ibuf_p[i].pwr_good_rst_b && gth_ibuf_p[i].reset_b)

disable iff (((gth_ibuf_p[i].pwr_good_rst_b || gth_ibuf_p[i].reset_b) !== 1)

我使用的命令是

:%s/disable iff (!(gth_ibuf_p[i\].pwr_good_rst_b && gth_ibuf_p[i\].reset_b)/disable iff (((gth_ibuf_p[i\].pwr_good_rst_b || gth_ibuf_p[i\].reset_b) !== 1)/gc 

它显示

the pattern is not found

我单独搜索了它所击中的这些模式。在 %s 中没有发生。

谁能帮我解决这个问题?

【问题讨论】:

  • :%s/禁用 iff (!(gth_ibuf_p[i].pwr_good_rst_b && gth_ibuf_p[i].reset_b)/禁用 iff (((gth_ibuf_p[i].pwr_good_rst_b || gth_ibuf_p[i]. reset_b) !== 1)/gc
  • 天哪,请学习如何正确格式化您的问题; cmets 也一样。通过缩进 4 个空格或用反引号括起来的简单代码突出显示。

标签: vim substitution


【解决方案1】:

只是:

:%s/\V..your.pattern..../..your..replacement../gc

:s/ 之后添加\V 以使用very nomagic。发送:h magic 以查看详细信息。

【讨论】:

  • 在一般情况下,您还需要放置` in front of every ` 和/:substitute 分隔符;您也可以使用不同的字符)。但是,您问题中的模式/替换没有任何这些。
猜你喜欢
  • 2023-04-11
  • 1970-01-01
  • 1970-01-01
  • 2021-05-16
  • 2015-01-25
  • 2011-08-16
  • 1970-01-01
  • 1970-01-01
  • 2016-11-12
相关资源
最近更新 更多