cfans1993
V2EX  ›  问与答

:?^Chapter?,/^Chapter/s=grey=gray=g vim 查找替换,这句第二个问号是什么意思?

  •  
  •   cfans1993 · Apr 10, 2016 · 2282 views
    This topic created in 3689 days ago, the information mentioned may be changed or developed.

    查找两个 Chapter 中的 grey ,并将 grep 替换成 grap ,可我就是不明白第二个?是什么意思

    2 replies    2016-04-10 23:21:58 +08:00
    wittyfox
        1
    wittyfox  
       Apr 10, 2016 via Android
    从哪看的?
    feiyuanqiu
        2
    feiyuanqiu  
       Apr 10, 2016
    你直接用 vim 试一试就知道了
    s 操作的结构是这样的::[range]s[ubstitute]/{pattern}/{string}/[flags]

    :?^Chapter?,/^Chapter/ 指定范围。?^Chapter? 和 /^Chapter/ 是一样的,都是一个正则,表示任何非 Chapter 的词,?和 / 都是分隔符。连起来的意思就是选中两个 Chapter 之间的内容

    s=grey=gray=g 全局替换 grey 为 gray ,这里用 = 作为 s 操作的分隔符
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4033 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 00:54 · PVG 08:54 · LAX 17:54 · JFK 20:54
    ♥ Do have faith in what you're doing.