用么样Vim进行多文件的字符串批替换

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

用么样Vim进行多文件的字符串批替换

hongqing lv
想要替换多个PHP文件中的一个单词到别外一个单词.但是发现VIM好象没有这个功能.UrtraEdit,EditPlus都没有这个功能.
UtrlaEdit和Editplus都只能替换打开的文件.不能替换一个目录下的所有的指定的文件.
可以用VIM的vimgrep命令查找多个文件.然后再用copen打开查找的结果列表.但是
怎么样用一个命令进行把找到的结果进行批替换呢.
sed在windows平台上不好用.也不能进行Utf-8编码文件的替换.
想不出有什么好办法了.大家有什么好办法吗?
 

hongqing.lv
2008-01-07

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

Jiahua Huang
请在 vim 看 :help argdo

你要的可以用

:args *.php
:argdo %s/旧/新/ge  |  update


不过既然会点 shell,为啥不直接在 linux 机器做呢

On Jan 7, 2008 8:54 AM, hongqing.lv <[hidden email]> wrote:
>
>
> 想要替换多个PHP文件中的一个单词到别外一个单词.但是发现VIM好象没有这个功能.
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

hongqing lv
真厉害.好用.谢谢.
我想递归替换目录以及子目录里的所有PHP文件.当前是用两句写的.
args **/*.php
argdo .....
 谢谢.
 

hongqing.lv
2008-01-07

发件人: Jiahua Huang
发送时间: 2008-01-07 09:07:53
收件人: [hidden email]; python. cn
抄送:
主题: Re: [python-chinese]用么样Vim进行多文件的字符串批替换
 
请在 vim 看 :help argdo
 
你要的可以用
 
:args *.php
:argdo %s/旧/新/ge  |  update
 
 
不过既然会点 shell,为啥不直接在 linux 机器做呢
 
On Jan 7, 2008 8:54 AM, hongqing.lv  <[hidden email] > wrote:
>
>
> 想要替换多个PHP文件中的一个单词到别外一个单词.但是发现VIM好象没有这个功能.
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

篱笆
强人!~  vim也这么强.

在08-1-7,hongqing.lv <[hidden email]> 写道:
真厉害.好用.谢谢.
我想递归替换目录以及子目录里的所有PHP文件.当前是用两句写的.
args **/*.php
argdo .....
 谢谢.
 

<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://hongqing.lv/" target="_blank">hongqing.lv
2008-01-07

发件人: Jiahua Huang
发送时间: 2008-01-07 09:07:53
收件人: [hidden email]; python. cn
抄送:
主题: Re: [python-chinese]用么样Vim进行多文件的字符串批替换
 
请在 vim 看 :help argdo
 
你要的可以用
 
:args *.php
:argdo %s/旧/新/ge  |  update
 
 
不过既然会点 shell,为啥不直接在 linux 机器做呢
 
On Jan 7, 2008 8:54 AM, <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://hongqing.lv/" target="_blank">hongqing.lv  <[hidden email] > wrote:
>
>
> 想要替换多个PHP文件中的一个单词到别外一个单词.但是发现VIM好象没有这个功能.
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank">http://python.cn/mailman/listinfo/python-chinese

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to   [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank"> http://python.cn/mailman/listinfo/python-chinese



--
分享免费、小巧、实用、有趣、绿色的软件 - 我们的口号是:没有流氓 一个ExE搞定一切!
谢谢各位支持本站! http://www.onexe.com
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

Jiahua Huang
VIM 可是编辑器之王呐,
( emacs 是操作系统而不是编辑器)

On Jan 7, 2008 9:28 AM, 篱笆 <[hidden email]> wrote:
> 强人!~  vim也这么强.
>
>
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

@@-2
In reply to this post by hongqing lv
UE好像有这个功能啊。

On 1/7/08, hongqing.lv <[hidden email]> wrote:
想要替换多个PHP文件中的一个单词到别外一个单词.但是发现VIM好象没有这个功能.UrtraEdit,EditPlus都没有这个功能.
UtrlaEdit和Editplus都只能替换打开的文件.不能替换一个目录下的所有的指定的文件.
可以用VIM的vimgrep命令查找多个文件.然后再用copen打开查找的结果列表.但是
怎么样用一个命令进行把找到的结果进行批替换呢.
sed在windows平台上不好用.也不能进行Utf-8编码文件的替换.
想不出有什么好办法了.大家有什么好办法吗?
 

<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://hongqing.lv/" target="_blank">hongqing.lv
2008-01-07

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank"> http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

Bugzilla from anderson922220@163.com
vim录制到寄存器脚本里面,打开文件时自动执行,完全可以实现。

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

Jiahua Huang
早给出了命令都,

用不着录制

On Jan 7, 2008 5:20 PM, anderson <[hidden email]> wrote:
> vim录制到寄存器脚本里面,打开文件时自动执行,完全可以实现。
>
>
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

? ?-5
太好    太强大了 每每有新鲜之感
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: 用么样Vim进行多文件的字符串批替换

Bugzilla from anderson922220@163.com
In reply to this post by Bugzilla from anderson922220@163.com
anderson 写道:
vim录制到寄存器脚本里面,打开文件时自动执行,完全可以实现。

  
汗,看的不够仔细,原来还
有这几个方法.

*26.3*    Making a change in many files

Suppose you have a variable called "x_cnt" and you want to change it to
"x_counter".  This variable is used in several of your C files.  You need to
change it in all files.  This is how you do it.
   Put all the relevant files in the argument list: >

    :args *.c
<
This finds all C files and edits the first one.  Now you can perform a
substitution command on all these files: >

    :argdo %s/\<x_cnt\>/x_counter/ge | update

The ":argdo" command takes an argument that is another command.  That command
will be executed on all files in the argument list.
   The "%s" substitute command that follows works on all lines.  It finds the
word "x_cnt" with "\<x_cnt\>".  The "\<" and "\>" are used to match the whole
word only, and not "px_cnt" or "x_cnt2".
   The flags for the substitute command include "g" to replace all occurrences
of "x_cnt" in the same line.  The "e" flag is used to avoid an error message
when "x_cnt" does not appear in the file.  Otherwise ":argdo" would abort on
the first file where "x_cnt" was not found.
   The "|" separates two commands.  The following "update" command writes the
file only if it was changed.  If no "x_cnt" was changed to "x_counter" nothing
happens.

There is also the ":windo" command, which executes its argument in all
windows.  And ":bufdo" executes its argument on all buffers.  Be careful with
this, because you might have more files in the buffer list than you think.
Check this with the ":buffers" command (or ":ls").


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese