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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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_Count_Match - Fatal编程技术网

无法计算Vim中的匹配数

无法计算Vim中的匹配数,vim,count,match,Vim,Count,Match,如何计算Vim中的匹配数 例如,对于文本 <? :%s/描述了您的目标 :%s/<?/whatever/ng :%s/ 在VIM 6.3中,您可以这样做: :set report=0 :%s/<?/&/g # returns the count without substitution :%s/<?/&/gn # returns the count without substitution :设置报告=0 :%s/I收到错误消息“尾部字符”

如何计算Vim中的匹配数

例如,对于文本

<?
:%s/描述了您的目标

:%s/<?/whatever/ng
:%s/
在VIM 6.3中,您可以这样做:

:set report=0
:%s/<?/&/g   # returns the count without substitution
:%s/<?/&/gn   # returns the count without substitution
:设置报告=0

:%s/I收到错误消息“尾部字符”。我也尝试了使用“:set report=0”的代码。我会再试一次,尾随字符的帮助描述了“一个参数已添加到一个不允许的Ex命令中。”Hrmm。。对不起,玛西,我不知道你怎么了。我只是在我的机器上的vim缓冲区中再次检查了这一点,它工作正常。如果你从web浏览器复制/粘贴代码,你可能会得到一个尾随的换行符(^M)。试着手动输入。@Brian:我找到了问题的根源。我的服务器上的Vim版本是6.3。当我在Vim 7.2上运行它时,代码工作得非常好。谢谢你的帮助!
:set report=0
:%s/<?/&/g   # returns the count without substitution
:%s/<?/&/gn   # returns the count without substitution