简体   繁体   English

使用emacs在一组文件前添加一行文本

[英]prepend a line of text to a set of files using emacs

Is there any way of prepending a line of text to a set of files within emacs? 是否可以在emacs中将一行文本添加到一组文件之前?

I can do search and replace across files using find-grep-dired , then marking the files and doing a target string - replacement string 我可以使用find-grep-dired搜索并替换文件,然后标记文件并执行目标字符串-替换字符串

But in this instance I don't want to 'replace' anything just prepend a single line to the start of a set of files with the '.ini' extension. 但是在这种情况下,我不想“替换”任何内容,而只是在扩展名为“ .ini”的一组文件的开头添加一行。

In emacs regular expressions, \\` matches the beginning of the buffer. 在emacs正则表达式中, \\`匹配缓冲区的开头。 So if you have all the files marked in a dired buffer, just do a dired-do-query-replace-regexp ( Q ) and replace \\` with the line you'd like to prepend. 因此,如果您将所有文件都标记在Dired缓冲区中,则只需执行dired-do-query-replace-regexpQ )并将\\`替换为您想添加的行即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM