Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vim 标记重复行并从结果中排除字符_Vim_Duplicates_Vim Syntax Highlighting - Fatal编程技术网

Vim 标记重复行并从结果中排除字符

Vim 标记重复行并从结果中排除字符,vim,duplicates,vim-syntax-highlighting,Vim,Duplicates,Vim Syntax Highlighting,我使用一行程序查找文本文件中的重复行: :syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch 当我在C源文件上执行它时,它正确地返回了这么多{和break;和空行。但是,它们不是最有趣的行。但是,我怎么能从这一行的结果中排除一个或多个字符呢?哇,这很难。 但我想我明白了: :syn clear

我使用一行程序查找文本文件中的重复行:

:syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch
当我在
C
源文件上执行它时,它正确地返回了这么多
{
break;
和空行。但是,它们不是最有趣的行。但是,我怎么能从这一行的结果中排除一个或多个字符呢?

哇,这很难。 但我想我明白了:

:syn clear Repeat | g/^\(^\(\(\s*break\;\|\s*{\|\s*}\)\@!.\).*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch
它忽略以下3种模式:

\s*break;
\s*}
\s*{
您可以在列表中添加更多广告,以
\\124;
分隔

正如您很容易发现的,它并不是一个很好的可读性解决方案。您可以使用
非常神奇的模式来改进它。请参见:h\v
。但是为什么您甚至需要对两行相同的代码进行测试呢?也许对于您的整个用例有更好的解决方案