jke*_*ian 4 regex vim regex-negation
我想为任何不遵循以下模式之一的左大括号创建匹配模式:
{\n\n
{\s*\/\/.*\n\(\s*\/\/.*\)\?\n
更普遍的问题是突出显示工作中违反编码规范的行为,这会强制执行空行 {
澄清,我正在寻找这样的代码,如下所示:
if (foo) {
this_is_bad____no_blank_line_above();
} else {this_is_worse();}
while (1) { //This comment is allowed
//This one too
theres_nothing_wrong_with_this();
}
if (foo) {
....//<-- Ideally we could mark this as bad, due to the spaces here
otherwise_perfectly_good();
}
Run Code Online (Sandbox Code Playgroud)
我真正需要的是: {\(\n\n\|\s*\/\/.*\n\(\s*\/\/.*\)\?\n\)\!
制作符号\!
表示"与这两个选项中的任何一个都不匹配".我看到了为个别角色做这种方式的方法,但不是更长的字符串.
找到了:
我在寻找 \@!
记录在 :h /\@!
{\(\n\n\|\s*\/\/.*\n\(\s*\/\/.*\)\?\n\)\@!
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1106 次 |
最近记录: |