:tabdo <range>s/.../.../
:windo <range>s/.../.../
:bufdo <range>s/.../.../ | w
我在 bufdo 版本中添加了一个写入命令,因为它可以' t 移至下一个缓冲区而不保存当前缓冲区。如果你想立即写作,你也可以为其他人这样做,但他们不需要。打开所有文件取决于您 - 最简单的方法就是 vim 将它们作为缓冲区,或者 vim -o < /code> 将它们作为窗口(使用 -O 垂直分割而不是水平分割)。
Check it out:
s/<a href\(\_[^>]*\)>/<a href\L\1>/
This says: match <a href, followed by zero or more characters besides >, including newlines (indicated by \_), and then finally a >. Replace it with <a href, the captured text converted to lowercase (indicated by \L), and the trailing >.
Obviously you're on your own if there's a > somewhere inside your tag, but such is life.
(And in case it's not clear, you'll use this as :%s/.../... or :<range>s/.../.../ for some smaller range.)
To use this on multiple files, you'll use windo, bufdo, or tabdo (depending on whether the files are open as tabs, windows, or just as buffers). There's a lot of documentation out there:
In general, it'll probably look something like this:
:tabdo <range>s/.../.../
:windo <range>s/.../.../
:bufdo <range>s/.../.../ | w
I've added a write command to the bufdo version, because it can't move on to the next buffer without saving the current one. You could do this for the others too, if you wanted to write immediately, but they'll work without. It's up to you to get all the files open - the easiest way is just vim <lots of files> to get them as buffers, or vim -o <lots of files> to get them as windows (use -O to split vertically instead of horizontally).
发布评论
评论(1)
检查一下:
这表示:匹配
,后跟除
>
之外的零个或多个字符,包括换行符(由\_
),最后是>
。将其替换为、捕获的文本转换为小写(由
\L
表示)以及结尾的>
。显然,如果您的标签内有
>
,您就得靠自己了,但这就是生活。(如果不清楚,您可以将其用作
:%s/.../...
或:s/.../... /
对于一些较小的范围。)要使用它多个文件,您将使用
windo
、bufdo
或tabdo
(具体取决于文件是以选项卡、窗口还是仅以选项卡形式打开)缓冲区)。有很多文档:一般来说,它可能看起来像这样:
我在 bufdo 版本中添加了一个写入命令,因为它可以' t 移至下一个缓冲区而不保存当前缓冲区。如果你想立即写作,你也可以为其他人这样做,但他们不需要。打开所有文件取决于您 - 最简单的方法就是
vim
将它们作为缓冲区,或者vim -o< /code> 将它们作为窗口(使用
-O
垂直分割而不是水平分割)。Check it out:
This says: match
<a href
, followed by zero or more characters besides>
, including newlines (indicated by\_
), and then finally a>
. Replace it with<a href
, the captured text converted to lowercase (indicated by\L
), and the trailing>
.Obviously you're on your own if there's a
>
somewhere inside your tag, but such is life.(And in case it's not clear, you'll use this as
:%s/.../...
or:<range>s/.../.../
for some smaller range.)To use this on multiple files, you'll use
windo
,bufdo
, ortabdo
(depending on whether the files are open as tabs, windows, or just as buffers). There's a lot of documentation out there:In general, it'll probably look something like this:
I've added a write command to the bufdo version, because it can't move on to the next buffer without saving the current one. You could do this for the others too, if you wanted to write immediately, but they'll work without. It's up to you to get all the files open - the easiest way is just
vim <lots of files>
to get them as buffers, orvim -o <lots of files>
to get them as windows (use-O
to split vertically instead of horizontally).