Python论坛  - 讨论区

标题:[python-chinese] 用么样Vim进行多文件的字符串批替换

2008年01月07日 星期一 08:54

hongqing.lv hongqing.lv在gmail.com
星期一 一月 7 08:54:20 HKT 2008

ÏëÒªÌæ»»¶à¸öPHPÎļþÖеÄÒ»¸öµ¥´Êµ½±ðÍâÒ»¸öµ¥´Ê£®µ«ÊÇ·¢ÏÖVIMºÃÏóûÓÐÕâ¸ö¹¦ÄÜ£®UrtraEdit£¬EditPlus¶¼Ã»ÓÐÕâ¸ö¹¦ÄÜ£®
UtrlaEditºÍEditplus¶¼Ö»ÄÜÌæ»»´ò¿ªµÄÎļþ£®²»ÄÜÌæ»»Ò»¸öĿ¼ÏµÄËùÓеÄÖ¸¶¨µÄÎļþ£®
¿ÉÒÔÓÃVIMµÄvimgrepÃüÁî²éÕÒ¶à¸öÎļþ£®È»ºóÔÙÓÃcopen´ò¿ª²éÕҵĽá¹ûÁÐ±í£®µ«ÊÇ
ÔõôÑùÓÃÒ»¸öÃüÁî½øÐаÑÕÒµ½µÄ½á¹û½øÐÐÅúÌæ»»ÄØ£®
sedÔÚwindowsƽ̨Éϲ»ºÃÓã®Ò²²»ÄܽøÐÐUtf-8±àÂëÎļþµÄÌæ»»£®
Ïë²»³öÓÐʲôºÃ°ì·¨ÁË£®´ó¼ÒÓÐʲôºÃ°ì·¨Âð£¿




hongqing.lv
2008-01-07
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080107/cfbfe17d/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 09:06

Jiahua Huang jhuangjiahua在gmail.com
星期一 一月 7 09:06:41 HKT 2008

请在 vim 看 :help argdo

你要的可以用

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


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

On Jan 7, 2008 8:54 AM, hongqing.lv <hongqing.lv at gmail.com> wrote:
>
>
> 想要替换多个PHP文件中的一个单词到别外一个单词.但是发现VIM好象没有这个功能.

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 09:23

hongqing.lv hongqing.lv在gmail.com
星期一 一月 7 09:23:58 HKT 2008

ÕæÀ÷º¦.ºÃÓÃ.лл.
ÎÒÏëµÝ¹éÌ滻Ŀ¼ÒÔ¼°×ÓĿ¼ÀïµÄËùÓÐPHPÎļþ.µ±Ç°ÊÇÓÃÁ½¾äдµÄ.
args **/*.php
argdo .....
 лл.




hongqing.lv
2008-01-07



·¢¼þÈË£º Jiahua Huang
·¢ËÍʱ¼ä£º 2008-01-07 09:07:53
ÊÕ¼þÈË£º python-chinese在lists.python.cn; 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  <hongqing.lv在gmail.com > wrote:
>
>
> ÏëÒªÌæ»»¶à¸öPHPÎļþÖеÄÒ»¸öµ¥´Êµ½±ðÍâÒ»¸öµ¥´Ê£®µ«ÊÇ·¢ÏÖVIMºÃÏóûÓÐÕâ¸ö¹¦ÄÜ£®
_______________________________________________
python-chinese
Post: send python-chinese在lists.python.cn
Subscribe: send subscribe to python-chinese-request在lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080107/6f0d8bb7/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 09:28

篱笆 nameliba在gmail.com
星期一 一月 7 09:28:03 HKT 2008

Ç¿ÈË!~  vimÒ²Õâôǿ.

ÔÚ08-1-7£¬hongqing.lv <hongqing.lv在gmail.com> дµÀ£º
>
>  ÕæÀ÷º¦.ºÃÓÃ.лл.
> ÎÒÏëµÝ¹éÌ滻Ŀ¼ÒÔ¼°×ÓĿ¼ÀïµÄËùÓÐPHPÎļþ.µ±Ç°ÊÇÓÃÁ½¾äдµÄ.
> args **/*.php
> argdo .....
>  лл.
>
>  ------------------------------
>  hongqing.lv
> 2008-01-07
>  ------------------------------
>  *·¢¼þÈË£º* Jiahua Huang
> *·¢ËÍʱ¼ä£º* 2008-01-07 09:07:53
> *ÊÕ¼þÈË£º* python-chinese在lists.python.cn; 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  <hongqing.lv在gmail.com > wrote:
> >
> >
> > ÏëÒªÌæ»»¶à¸öPHPÎļþÖеÄÒ»¸öµ¥´Êµ½±ðÍâÒ»¸öµ¥´Ê£®µ«ÊÇ·¢ÏÖVIMºÃÏóûÓÐÕâ¸ö¹¦ÄÜ£®
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
·ÖÏíÃâ·Ñ¡¢Ð¡ÇÉ¡¢ÊµÓá¢ÓÐȤ¡¢ÂÌÉ«µÄÈí¼þ - ÎÒÃǵĿںÅÊÇ£ºÃ»ÓÐÁ÷Ã¥ Ò»¸öExE¸ã¶¨Ò»ÇÐ!
лл¸÷λ֧³Ö±¾Õ¾! http://www.onexe.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080107/9fc82f96/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 09:42

Jiahua Huang jhuangjiahua在gmail.com
星期一 一月 7 09:42:13 HKT 2008

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

On Jan 7, 2008 9:28 AM, 篱笆 <nameliba at gmail.com> wrote:
> 强人!~  vim也这么强.
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 17:12

@@ askfor在gmail.com
星期一 一月 7 17:12:13 HKT 2008

UEºÃÏñÓÐÕâ¸ö¹¦ÄÜ°¡¡£

On 1/7/08, hongqing.lv <hongqing.lv在gmail.com> wrote:
>
>  ÏëÒªÌæ»»¶à¸öPHPÎļþÖеÄÒ»¸öµ¥´Êµ½±ðÍâÒ»¸öµ¥´Ê£®µ«ÊÇ·¢ÏÖVIMºÃÏóûÓÐÕâ¸ö¹¦ÄÜ£®UrtraEdit£¬EditPlus¶¼Ã»ÓÐÕâ¸ö¹¦ÄÜ£®
> UtrlaEditºÍEditplus¶¼Ö»ÄÜÌæ»»´ò¿ªµÄÎļþ£®²»ÄÜÌæ»»Ò»¸öĿ¼ÏµÄËùÓеÄÖ¸¶¨µÄÎļþ£®
> ¿ÉÒÔÓÃVIMµÄvimgrepÃüÁî²éÕÒ¶à¸öÎļþ£®È»ºóÔÙÓÃcopen´ò¿ª²éÕҵĽá¹ûÁÐ±í£®µ«ÊÇ
> ÔõôÑùÓÃÒ»¸öÃüÁî½øÐаÑÕÒµ½µÄ½á¹û½øÐÐÅúÌæ»»ÄØ£®
> sedÔÚwindowsƽ̨Éϲ»ºÃÓã®Ò²²»ÄܽøÐÐUtf-8±àÂëÎļþµÄÌæ»»£®
> Ïë²»³öÓÐʲôºÃ°ì·¨ÁË£®´ó¼ÒÓÐʲôºÃ°ì·¨Âð£¿
>
>  ------------------------------
>  hongqing.lv
> 2008-01-07
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080107/5c019b4c/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 17:20

anderson anderson922220在163.com
星期一 一月 7 17:20:06 HKT 2008

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


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 17:58

Jiahua Huang jhuangjiahua在gmail.com
星期一 一月 7 17:58:36 HKT 2008

早给出了命令都,

用不着录制

On Jan 7, 2008 5:20 PM, anderson <anderson922220 at 163.com> wrote:
> vim录制到寄存器脚本里面,打开文件时自动执行,完全可以实现。
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月07日 星期一 18:01

? ? asmasters在gmail.com
星期一 一月 7 18:01:22 HKT 2008

太好    太强大了 每每有新鲜之感
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20080107/6e4f8be4/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2008年01月08日 星期二 10:57

anderson anderson922220在163.com
星期二 一月 8 10:57:30 HKT 2008

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_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 "\". 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").
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080108/d9afecd9/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号