命令删除vim中的所有空格

时间:2018-09-18 06:32:13

标签: vim

我希望能够使用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

2 个答案:

答案 0 :(得分:4)

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

:%s/\s//g

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

答案 1 :(得分:0)

如果您只想在单引号内修剪空格,这应该可行:

:%s/= '\zs\s*\(\S*\)\s*'/\1'/g
相关问题