Ⅰ. 插件描述

Lightweight, customizable and functional Vim plugin for JSHint integration.

Ⅱ. 基本信息

创建日期:  2013-06-27
使用用户:  370
Github星:  264
插件作者:  Nikolay Frantsev

Ⅲ. 安装方法


Plugin 'shutnik/jshint2-vim'
… 然后在Vim中运行以下命令:
:source %

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。


NeoBundle 'shutnik/jshint2-vim'
… 然后在Vim中运行以下命令:
:source %


Plug 'shutnik/jshint2-vim'
… 然后在Vim中运行以下命令:
:source %


cd ~/.vim/bundle
git clone https://github.com/shutnik/jshint2.vim

Ⅳ. 文档说明

# jshint2.vim

Lightweight, customizable and functional Vim plugin for JSHint integration.



  • Linting whole file or selected lines without saving to disk.
  • Using project-specific (locally installed) version of JSHint and JSHint configuration files if available.
  • Setting lint flags from command line with autocompletion.
  • Optionally opening list of linting errors with useful shortcuts.
  • Optionally validating files after reading or saving.
  • Working on Linux, Windows (with JSHint 2.1.5 and newer) and OS X.


  1. Install Node.js and JSHint.
  2. Clone plugin into your ~/.vim/bundle/jshint2.vim/.
  3. Install Pathogen or just add set runtimepath+=~/.vim/bundle/jshint2.vim/ into your .vimrc.
  4. Optionally place .jshintrc into your home and/or project directory.
  5. ???
  6. PROFIT!


Use :JSHint command inside Vim to lint whole file or :'<,'>JSHint to lint only selected lines.
Add ! to suppress opening error list (number of lint errors still will be shown), add space and use tab key to complete space separated lint flags — :JSHint! white:true eqeqeq:true. Use - to ignore errors by their codes — :JSHint -E001 -W002 -I003.

Error List Shortcuts

t — open error in new tab.
T — open error in new tab with error list.
v — open error in new vertical split.
V — open error in new vertical split with error list.
s — open error in new horizontal split.
S — open error in new horizontal split with error list.
i — ignore selected error.
n — scroll to selected error.
q — close error list.


Set global JSHint command path (mostly for Windows):

let jshint2_command = '~/path/to/node_modules/.bin/jshint'

Lint JavaScript files after reading it:

let jshint2_read = 1

Lint JavaScript files after saving it:

let jshint2_save = 1

Do not automatically close orphaned error lists:

let jshint2_close = 0

Skip lint confirmation for non JavaScript files:

let jshint2_confirm = 0

Do not use colored messages:

let jshint2_color = 0

Hide error codes in error list (if you don't use error ignoring or error codes confuses you):

let jshint2_error = 0

Set min and max height of error list:

let jshint2_min_height = 3
let jshint2_max_height = 12


Quick lint mapping:

" jshint validation
nnoremap <silent><F1> :JSHint<CR>
inoremap <silent><F1> <C-O>:JSHint<CR>
vnoremap <silent><F1> :JSHint<CR>

" show next jshint error
nnoremap <silent><F2> :lnext<CR>
inoremap <silent><F2> <C-O>:lnext<CR>
vnoremap <silent><F2> :lnext<CR>

" show previous jshint error
nnoremap <silent><F3> :lprevious<CR>
inoremap <silent><F3> <C-O>:lprevious<CR>
vnoremap <silent><F3> :lprevious<CR>

Author & License

Written by Nikolay S. Frantsev under GNU GPL 3 License.