我将Vim与Syntastic和JSHint结合使用,并且有一些我想修复的小故障行为。
这是我的.vimrc文件:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" React.js/JSX syntax highlighting
"Plugin 'mxw/vim-jsx'
"
"JSHint
Plugin 'wookiehangover/jshint.vim'
"Syntastic
Plugin 'scrooloose/syntastic'
"Syntastic configuration
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_html_tidy_exec = 'tidy5'
let g:syntastic_javascript_checkers = ['jshint']
let g:JSHintHighlightErrorLine = 0
syntax on
set t_Co=256
set ai
set shiftwidth=4
set tabstop=4
set number
"colorscheme monokai
colorscheme skittles_berry
感谢您提供的任何帮助。
答案 0 :(得分:0)
我不知道你的^M
问题和崩溃问题来自哪里,但你不需要这么大的插件来完成这么简单的任务。
创建~/.vim/after/ftplugin/javascript.vim
如果它不存在并粘贴以下行:
jshint的错误格式
setlocal errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%#
告诉Vim使用jshint作为:make
命令
setlocal makeprg=jshint
在写入时添加自动命令以在当前文件上运行:make
,一旦打开quickfix窗口,最后的| silent wincmd p
会将焦点切换回编辑窗口
autocmd! BufWritePost <buffer> silent make % | silent redraw! | silent wincmd p
我从未遇到过这种简单设置或^M
问题的单一崩溃。
有了这个,你应该在:w
之后获得类似的东西:
<C-w>p
。:cprevious
/ :cnext
。参考:
:help 'errorformat'
:help 'makeprg'
:help autocmd
:help bufwritepost
:help :silent
:help :redraw
:help :wincmd
:help quickfix
另外,请查看这篇精彩帖子:The Power of Vim