013231
V2EX  ›  Vim

Vim中怎样把不能与指定正则表达式匹配的行都删掉?

  •  
  •   013231 · Jan 13, 2012 · 5401 views
    This topic created in 5242 days ago, the information mentioned may be changed or developed.
    对于文件的每一行, 如果可以和指定正则表达式匹配就保留, 否则就删除. 也就是说相当于grep过滤的效果. 在Vim中应该怎么做呢?
    2 replies    1970-01-01 08:00:00 +08:00
    Vim
        1
    Vim  
       Jan 13, 2012
    :v/pattern/d
    或者
    :g!/pattern/d
    mybeky
        2
    mybeky  
       Jan 13, 2012
    :v/PATTERN/d
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4103 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:14 · PVG 12:14 · LAX 21:14 · JFK 00:14
    ♥ Do have faith in what you're doing.