0

我在 vim 中使用 syntastic 和 youcompleteme。每当我离开插入模式并在我的代码中出现错误时,语法错误槽会出现一个红色标记,指示错误在哪里。我发现屏幕每次都会移动以便为排水沟腾出空间,这很烦人。我想知道是否可以设置 vim 以便排水沟始终留在那里。或者,如果可以将它们全部隐藏在一起,仍然可以看到红色的错误标记。我真的只是想避免发生的屏幕偏移。欢迎任何想法。在此先感谢您的帮助。

这是我的 .vimrc

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

""""""""" PLUGIN LIST STARTS HERE """"""""""""""""""""
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/syntastic'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tpope/vim-surround'
Plugin 'valloric/youcompleteme'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-repeat'
Plugin 'scrooloose/nerdtree'
Plugin 'sickill/vim-pasta'
Plugin 'itchyny/lightline.vim'
""""""""" PLUGIN LIST END HERE """"""""""""""""""""
call vundle#end()            " required
filetype plugin indent on    " requiredntax on

syntax on
set tabstop=4
set number
set smartindent
set shiftwidth=4
set mouse=a
set backspace=indent,eol,start
set colorcolumn+=80
highlight ColorColumn ctermbg=8
set completeopt-=preview
set laststatus=2

let &t_SI.="\e[5 q"
let &t_SR.="\e[4 q"
let &t_EI.="\e[1 q"


let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
map <F5> :NERDTreeToggle<CR>

let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++14 -stdlib=libc++'

function! Multiple_cursors_before()
  call AutoPairsToggle()
endfun

function! Multiple_cursors_after()
  call AutoPairsToggle()
endfun

let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
4

2 回答 2

1

我发现了这个,建议set signcolumn=yes在你的 .vimrc 中使用

https://superuser.com/questions/558876/how-can-i-make-the-sign-column-show-up-all-the-time-even-if-no-signs-have-been-a

顺便说一句,我最近了解到这个插件可以替代 syntastic。它基本上是一样的,除了它异步执行操作,这使得它执行得更快。不过,它确实需要 vim 8(或者我不熟悉的某些版本的 neovim)。我像 2 周前一样进行了切换,并且非常喜欢它(尽管我确实增加了 ALE 运行 linter 的超时时间)。

https://github.com/w0rp/ale

如果您切换到 ALE,他们专门有一个设置来保持标志排水沟打开,这正是您正在寻找的。

https://github.com/w0rp/ale#faq-keep-signs

于 2018-08-29T04:11:39.077 回答
0

v8.1.1564 开始,您可以在数字列中使用set signcolumn=number.

您将无法在任何有错误的行上看到数字,但它避免了缓冲区移动,并且不需要保持标志排水沟打开。

于 2020-04-17T08:06:00.483 回答