在 VIM 中查找并替换两个相邻的引号

在 VIM 中查找并替换两个相邻的引号

我有以下文字:

 "Complete","2014 H2","123456","Local","789123","File of files","A","142","000","Text",""Sharp Yield Rise
    -3.7%
    Flight to Quality
    -5.6%
    Liquidity Crisis
    -11.1%
    Equity Crash
    -2.5%
    Credit Crisis
    -9.7%""^M

我需要将其替换为:

"Complete","2014 H2","123456","Local","789123","File of files","A","142","000","Text","Sharp Yield Rise
    -3.7%
    Flight to Quality
    -5.6%
    Liquidity Crisis
    -11.1%
    Equity Crash
    -2.5%
    Credit Crisis
    -9.7%"^M

基本上我想用“”代替锋利的和之前^M(EOL 字符)。

答案1

:%s/""/"/g

  • 只需在普通模式下输入该内容,最后点击Enter

    • 如果您处于插入模式(可以在文件中输入文本),请点击Esc返回正常模式以退出该模式。
  • %范围说明符意味着对整个文件进行操作。

  • 全局修饰符/g表示替换指定范围内的所有匹配项 - 默认情况下,:substitute仅替换每行中的第一个匹配项。

相关内容