请问如何删除多余的空格?

56 views
Skip to first unread message

jiaobanli

unread,
Oct 5, 2006, 2:11:43 AM10/5/06
to Vim.cn
我从网上copy了一篇文章,准备修改一下再用latex排一下版。可是这篇文章每段第一句前面都加了几个空格(中文的段首缩进),我希望可以把这些空格全部删除。可是不知道怎么办好。

tocer

unread,
Oct 5, 2006, 3:38:55 AM10/5/06
to Vim...@googlegroups.com
:%s/^\s+//gc

jiaobanli wrote::

DaVinci

unread,
Oct 5, 2006, 6:21:59 AM10/5/06
to Vim.cn

tocer wrote:
> :%s/^\s+//gc
>
怎么解释这个命令?

lanser

unread,
Oct 5, 2006, 9:23:07 AM10/5/06
to Vim...@googlegroups.com
%s     全文搜索
/^\s+   一个或多个空格开头
//        换成nothing
gc      替换所有,替换前询问

DaVinci

unread,
Oct 6, 2006, 5:08:54 AM10/6/06
to Vim.cn

lanser wrote:
> %s 全文搜索
> /^\s+ 一个或多个空格开头
> // 换成nothing
> gc 替换所有,替换前询问

Thanks very much.

DaVinci

unread,
Oct 6, 2006, 6:50:18 AM10/6/06
to Vim.cn

lanser wrote:
> %s 全文搜索
> /^\s+ 一个或多个空格开头
> // 换成nothing
> gc 替换所有,替换前询问
>
如果是多个文件中进行替换应该怎么作呢?

tocer

unread,
Oct 6, 2006, 8:42:00 AM10/6/06
to Vim...@googlegroups.com
参见:
:h argdo
:h bufdo
:h windo
:h tabdo

这些都可以在多个文件中进行替换,当然还是有差别的,看帮助

DaVinci wrote::

bolow

unread,
Oct 9, 2006, 8:11:33 AM10/9/06
to Vim...@googlegroups.com
:%s/^\s\+//gc
加号前面有个杠
 

yuanlii

unread,
Oct 9, 2006, 8:18:52 PM10/9/06
to Vim.cn
why?

tocer

unread,
Oct 10, 2006, 2:57:57 AM10/10/06
to Vim...@googlegroups.com
呵呵,你说得对,我老和Python的正则表达式混:(

bolow wrote::
> :%s/^\s\+//gc
> 加号前面有个杠
>
> >

tocer

unread,
Oct 10, 2006, 2:58:28 AM10/10/06
to Vim...@googlegroups.com
:h \+

yuanlii wrote::
> why?
>
>
> >

Reply all
Reply to author
Forward
0 new messages