您如何使用vim的quickfix功能? [英] How do you use vim's quickfix feature?

查看:117
本文介绍了您如何使用vim的quickfix功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个非常新的Vim用户,我发现它的学习曲线相当陡峭(至少对我而言).我刚刚安装了此vim脚本用于JavaScriptLint错误检查,一旦我发现该错误就会在vim的快速修复窗口中显示错误保存缓冲区.

I'm a pretty new Vim user and I've found that its learning curve is quite steep (at least for me). I just installed this vim script for JavaScriptLint error checking, which shows errors in vim's quickfix window once I save a buffer.

但是,我不知道下一步该怎么做.如何滚动所有错误?如何关闭快速修复程序窗口"?更改代码后,如何获取它以检查错误?

However, I don't know what to do next.. How do I 'scroll' through all the errors? How do I close the quickfix 'window'? How do I get it to check for errors after I've made changes to my code?

我看过vim quickfix文档,但是命令数量不胜枚举,我似乎找不到我想要的东西.任何帮助将不胜感激.

I've looked at the vim quickfix docs but the amount of commands are overwhelming and I can't seem to find what I want. Any help would be appreciated.

一个附带的问题:有什么方法可以让javascriptlint检查驻留在.html文件中的代码的js错误吗?

A side question: is there any way to have javascriptlint check for js errors for code residing in a .html file?

谢谢!

推荐答案

有很多用于快速修复的命令,但是我倾向于发现我只使用了其中的一小部分:

There are a lot of commands for quickfix as you have said, but I tend to find I only use a small subset of them:

:copen " Open the quickfix window
:ccl   " Close it
:cw    " Open it if there are "errors", close it otherwise (some people prefer this)
:cn    " Go to the next error in the window
:cp    " Go to the previous error in the window
:cnf   " Go to the first error in the next file
:.cc   " Go to error under cursor (if cursor is in quickfix window)

我倾向于将它与:make:vimgrep一起使用,因此我无法对Javascript皮棉检查器进行评论,但这应该为您提供了一些入门知识.

I tend to use this with :make and :vimgrep, so I can't comment on the Javascript lint checker, but this should give you something to get started.

关于JavascriptLint的一般用法,我不是JavaScript程序员,但看起来该脚本公开了一个名为"JavascriptLint"的函数,因此,如果要手动调用它,可以使用:call JavascriptLint().但是,它可以在文件的磁盘副本上使用,因此必须首先保存.如果(且仅当)命令行jsl适用于html文件,您应该能够在html文件上使用:call JavascriptLint()来检查内部javascript.您也可以这样做:

Regarding the general use of JavascriptLint, I'm not a javascript programmer, but it looks like the script exposes a function called "JavascriptLint", so if you want to call it manually, you can use :call JavascriptLint(). However, it works on the disk copy of the file, so it'll have to be saved first. If (and only if) the command line jsl works on html files, you should be able to use :call JavascriptLint() on an html file to check the internal javascript. You could also do:

autocmd BufWritePost,FileWritePost *.html call JavascriptLint()

使其自动化.如果jsl不支持html文件,那么(不修补应用程序或要求作者对其进行更改),可能是一个丢失的原因...

to automate it. If jsl doesn't support html files, then (short of patching the application or asking the author to change it), it's probably a lost cause...

这篇关于您如何使用vim的quickfix功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆