【问题标题】:Command to remove all white spaces in vim删除vim中所有空格的命令
【发布时间】:2023-03-21 07:27:01
【问题描述】:

我希望能够使用 vim 删除 txt 文件中的所有空格

update reg04_rpt_animreg set birthdate = '      2016-01-21       ' where animalid = '   TZN000192803889  ';
update reg04_rpt_animreg set birthdate = '      2015-07-05       ' where animalid = '   TZN000192803890  ';
update reg04_rpt_animreg set birthdate = '      2011-12-12       ' where animalid = '   TZN000192803891  ';
update reg04_rpt_animreg set birthdate = '      2013-05-05       ' where animalid = '   TZN000192803893  ';
update reg04_rpt_animreg set birthdate = '      2013-04-02       ' where animalid = '   TZN000192803894  ';
update reg04_rpt_animreg set birthdate = '      2015-05-16       ' where animalid = '   TZN000192803895  ';

我在 vim 中使用了以下命令,但没有得到预期的输出

:g/^\s*$/d

【问题讨论】:

  • 如果您向我们展示所需的输出会更容易。

标签: vim


【解决方案1】:

我认为您正在寻找s 命令; :g/<regexp>/d 删除与<regexp> 匹配的整行。

:%s/\s//g

这将全局替换所有空格类型字符 (\s) (g)。

【讨论】:

    【解决方案2】:

    如果您只尝试修剪单引号内的空格,这应该可以:

    :%s/= '\zs\s*\(\S*\)\s*'/\1'/g
    

    【讨论】:

      猜你喜欢
      • 2016-02-04
      • 2012-02-09
      • 2011-09-26
      • 2010-10-06
      • 1970-01-01
      • 2016-01-27
      • 2019-08-13
      • 2013-06-22
      • 1970-01-01
      相关资源
      最近更新 更多