vim の quickfix 機能の使い方は? 質問する

vim の quickfix 機能の使い方は? 質問する

私はVim初心者ですが、Vimの学習曲線がかなり急であることがわかりました(少なくとも私にとっては)。このvimスクリプトJavaScriptLint エラー チェック用。バッファを保存すると、vim の quickfix ウィンドウにエラーが表示されます。

しかし、次に何をすればいいのかわかりません。すべてのエラーを「スクロール」するにはどうすればいいでしょうか。クイックフィックスの「ウィンドウ」を閉じるにはどうすればよいでしょうか。コードを変更した後でエラーをチェックするにはどうすればいいでしょうか。

vim quickfix のドキュメントを見ましたが、コマンドの数が多すぎて、必要なものが見つからないようです。どなたか助けていただければ幸いです。

補足質問ですが、javascriptlint で .html ファイル内にあるコードの js エラーをチェックする方法はありますか?

ベストアンサー1

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)

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.

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()

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...

おすすめ記事