I'm using Vim with Syntastic and JSHint, and there are a few bits of glitchy behavior that I'd like to fix.
我正在使用Vim with Syntastic和JSHint,还有一些我想解决的小问题。
- Whenever I modify the last character on a line of text and save (:w), I momentarily see "^M" flash after the text before (sometimes) vanishing. Sometimes it sticks around and I have to manually delete it. What's the deal with this and how do I prevent it?
- 每当我修改一行文本中的最后一个字符并保存(:w)时,我会在文本之前看到“^ M”闪烁(有时)消失。有时会粘在一起,我必须手动删除它。这有什么用处,我该如何预防呢?
- When there is an error in the quickfix view, how do I toggle focus between the quickfix view and the Vim editor window?
- 当quickfix视图中出现错误时,如何在quickfix视图和Vim编辑器窗口之间切换焦点?
- Vim crashes maybe once per minute, and I haven't the slightest clue as to why, but it's extremely annoying. The error typically reads "Vim: Caught deadly signal ABRT Vim: Finished. [1]6099 abort vi gulpfile.js" How do I prevent this?
- Vim可能每分钟崩溃一次,我没有丝毫知道为什么,但它非常烦人。该错误通常为“Vim:Caught致命信号ABRT Vim:已完成。[1] 6099 abort vi gulpfile.js”我如何防止这种情况?
Here is my .vimrc file:
这是我的.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
Thanks for any help you can provide.
感谢您的任何帮助,您可以提供。
1 个解决方案
#1
0
I have no idea where your ^M
issue and your crashing issue come from but you don't need such a huge plugin for such a simple task.
我不知道你的^ M问题和崩溃问题来自哪里,但你不需要这么大的插件来完成这么简单的任务。
Create ~/.vim/after/ftplugin/javascript.vim
if it doesn't exist and paste the lines below:
创建〜/ .vim / after / ftplugin / javascript.vim如果它不存在并粘贴以下行:
-
errorformat for jshint
jshint的errorformat
setlocal errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%#
-
tell Vim to use jshint for the
:make
command告诉Vim使用jshint作为:make命令
setlocal makeprg=jshint
-
add an autocommand to run
:make
on the current file upon write, the| silent wincmd p
at the end switches the focus back to the editing window once the quickfix window is opened添加一个自动命令来运行:在写入时对当前文件进行make,|一旦打开quickfix窗口,最后的无声wincmd p会将焦点切换回编辑窗口
autocmd! BufWritePost <buffer> silent make % | silent redraw! | silent wincmd p
I've never experienced a single crash with that simple setup, or that ^M
issue.
我从来没有经历过这种简单设置的单一崩溃,或者^ M问题。
With that in place you should get something like that after :w
:
有了这个,你应该得到类似的东西:w:
- To move the focus from/to the quickfix window, use
<C-w>p
. -
要将焦点从/移动到quickfix窗口,请使用
p。 - To jump to the previous/next error without using the quickfix window, use
:cprevious
/:cnext
. - 要在不使用quickfix窗口的情况下跳转到上一个/下一个错误,请使用:cprevious /:cnext。
Reference:
参考:
:help 'errorformat'
:help 'makeprg'
:help autocmd
:help bufwritepost
:help :silent
:help :redraw
:help :wincmd
:help quickfix
Also, check out this great post: The Power of Vim
另外,看看这篇伟大的帖子:Vim的力量
#1
0
I have no idea where your ^M
issue and your crashing issue come from but you don't need such a huge plugin for such a simple task.
我不知道你的^ M问题和崩溃问题来自哪里,但你不需要这么大的插件来完成这么简单的任务。
Create ~/.vim/after/ftplugin/javascript.vim
if it doesn't exist and paste the lines below:
创建〜/ .vim / after / ftplugin / javascript.vim如果它不存在并粘贴以下行:
-
errorformat for jshint
jshint的errorformat
setlocal errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%#
-
tell Vim to use jshint for the
:make
command告诉Vim使用jshint作为:make命令
setlocal makeprg=jshint
-
add an autocommand to run
:make
on the current file upon write, the| silent wincmd p
at the end switches the focus back to the editing window once the quickfix window is opened添加一个自动命令来运行:在写入时对当前文件进行make,|一旦打开quickfix窗口,最后的无声wincmd p会将焦点切换回编辑窗口
autocmd! BufWritePost <buffer> silent make % | silent redraw! | silent wincmd p
I've never experienced a single crash with that simple setup, or that ^M
issue.
我从来没有经历过这种简单设置的单一崩溃,或者^ M问题。
With that in place you should get something like that after :w
:
有了这个,你应该得到类似的东西:w:
- To move the focus from/to the quickfix window, use
<C-w>p
. -
要将焦点从/移动到quickfix窗口,请使用
p。 - To jump to the previous/next error without using the quickfix window, use
:cprevious
/:cnext
. - 要在不使用quickfix窗口的情况下跳转到上一个/下一个错误,请使用:cprevious /:cnext。
Reference:
参考:
:help 'errorformat'
:help 'makeprg'
:help autocmd
:help bufwritepost
:help :silent
:help :redraw
:help :wincmd
:help quickfix
Also, check out this great post: The Power of Vim
另外,看看这篇伟大的帖子:Vim的力量