zoukankan      html  css  js  c++  java
  • vim中的替换操作

      在vim中 :s(substitute)命令用于查找并替换字符串。使用方法如下:

    :s/<find-this>/<replace-with-this>/<flags>
    

      例如:

    1 :%s/foo/bar/g  # 在全局范围内(%)查找foo并将之替换为bar,所有出现都会被替换(g)
    2 :s/foo/bar/g  # 在当前行内查找foo并将之替换为bar,所有出现都会被替换(g)
    3 :'<,'>s/foo/bar/g  # 在选区内进行替换,Visual模式下选择区域后输入会自动补全'<,'>

      下面是一些可以加的flag.    for example,  :s/cat/dog/gi  会把cat.Cat() 变成 dog.dog().

      g —global replace: replace every occurrence of the pattern, not just the first one

      c —confirm each substitution: prompt the user before replacing the text

      e —do not show errors if no matches are found

      i —ignore case: make the search case-insensitive

      I —make the search case-sensitive

      最后说一个小tip: 程序员喜欢用foo和bar指代变量名: foo bar -> Fucked Up Beyond All Repair 完全无法修补。

  • 相关阅读:
    intel cpu 架构
    nginx-nagios-pnp4nagios-nrpe安装配置过程
    iostat 命令detail
    nagios环境
    编译安装PHP 5.3.13
    nagios支持PNP图形显示
    nagios配置安装
    在xp下禁用media sense
    linux awk常用命令【转载】
    sed命令解析[转载]
  • 原文地址:https://www.cnblogs.com/chester-cs/p/11605656.html
Copyright © 2011-2022 走看看