vim quickfix 插件定位出错

来源:互联网 发布:linux清除缓存 编辑:程序博客网 时间:2024/06/05 05:32

vim quickfix 插件在make的时候,能帮你快速定位错误,但是在中文环境下却容易出错。

quickfix的用法在vim中输入:help quickfix 即可获得。


解决办法设定终端的环境为英文:

export LANGUAGE=en_US.UTF-8
验证后可将设置添加到配置文件中

错误再现:

中文环境下在vim的命令行模式下编译工程,编译完成后在vim命令模式下输入

:cw 命令打开quickfix窗口

列出如下错误:

|| onvifDeviceIO.c: 在函数‘onvifCmdGetVideoOutputConfig’中:229 onvifDeviceIO.c|73 col 9| 警告: 变量‘id’被设定但未被使用 [-Wunused-but-set-variable]230 || onvifDeviceIO.c: 在函数‘onvifCmdSetVideoOutputConfig’中:231 onvifDeviceIO.c|125 col 5| 错误: ‘asdfadfadf’未声明(在此函数内第一次使用)232 onvifDeviceIO.c|125 col 5| 附注: 每个未声明的标识符在其出现的函数内只报告一次233 onvifDeviceIO.c|127 col 5| 错误: expected ‘;’ before ‘if’234 onvifDeviceIO.c|124 col 10| 警告: 未使用的变量‘videoOutputToken’ [-Wunused-variable]235 onvifDeviceIO.c|123 col 9| 警告: 未使用的变量‘id’ [-Wunused-variable


然后定位到231行打开onvifDeviceIO.c 时出现错误(编译时vim的所在路径与onvifDeviceIO.c所在路径不同)

如果在英文环境下如上的操作是不会错,能够正确定位到onvifComponent/onvifDeviceIO.c 125 行

 || onvifDeviceIO.c: In function ‘onvifCmdSetVideoOutputConfig’:231 onvifComponent/onvifDeviceIO.c|125 col 5| error: ‘asdfadfadf’ undeclared (first use in this function)232 onvifComponent/onvifDeviceIO.c|125 col 5| note: each undeclared identifier is reported only once for each           function it appears in233 onvifComponent/onvifDeviceIO.c|127 col 5| error: expected ‘;’ before ‘if’234 onvifComponent/onvifDeviceIO.c|124 col 10| warning: unused variable ‘videoOutputToken’ [-Wunused-variable]      235 onvifComponent/onvifDeviceIO.c|123 col 9| warning: unused variable ‘id’ [-Wunused-variable]236 onvifComponent/onvifDeviceIO.c|122 col 9| warning: unused variable ‘i’ [-Wunused-variable]


原因分析:(自己想的没有验证,知道或确认的朋友请留言)

中文环境下,如下的文件路径转换不会被vim识别记录,

94 || make[2]:正在离开目录 `/home/zhongxuan/workspace/epn4222/trunk/src/modules/networkCommandHandler/module'95 || PLATFORM=x86 make all -C onvifComponent96 || make[2]: 正在进入目录 `/home/zhongxuan/workspace/epn4222/trunk/src/modules/networkCommandHandler/

但是在英文环境下vim是可以识别如下的路径转换,所以在定位的时候就不会出错。

94 || make[2]: Leaving directory `/home/zhongxuan/workspace/epn4222/trunk/src/modules/networkCommandHandler/module'95 || PLATFORM=x86 make all -C onvifComponent96 || make[2]: Entering directory `/home/zhongxuan/workspace/epn4222/trunk/src/modules/networkCommandHandler/     

另外tmux下中文的搜索也是不行的,所以开发linux的开发环境还是选择英文比较好,免得出现莫名奇妙的错误。

原创粉丝点击