作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用以下全局命令根据其首字母对段落进行排序:
g/_p/,/^$/mo$
g/_p/,/^$/mo$|g/_w/,/^$/mo$
Cannot do :global recursive
最佳答案
:exe 'g/_p/,/^$/mo$' | g/_w/,/^$/mo$
global
命令,只需将它们包装在
execute
中:
:execute 'g/aaa/s//bbb/g ' | execute 'g/ccc/s/ddd//g' | execute 'g/eee/s/fff/ggg/g' | g/^cake/s/$/ is a lie/g
:help
:bar
中:
*:bar* *:\bar*
|
can be used to separate commands, so you can give multiple commands in one line. If you want to use|
in an argument, precede it with\
.These commands see the
|
as their argument, and can therefore not be followed by another Vim command:
- (.. list of commands ..)
:global
- (.. list of commands ..)
Note that this is confusing (inherited from Vi): With
:g
the|
is included in the command, with:s
it is not.To be able to use another command anyway, use the
:execute
command.
%s/htm/html/c | %s/JPEG/jpg/c | %s/GIF/gif/c
关于vim - 如何在Vim中顺序执行多个全局命令? (错误: "Cannot do :global recursive"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9750697/
我是一名优秀的程序员,十分优秀!