YouCompleteme 有效但无法使用 TAB 完成

YouCompleteme works but can not complete using TAB

我使用 vundle 安装了 YouCompleteMe。 然后安装所有插件并使用

安装 YCM
./install.sh --clang-completer

这是我的 vimrc 的样子:

syntax on
set expandtab
set cindent
set tabstop=4
retab
set shiftwidth=4
set hlsearch
set paste
set ic
set number
colorscheme molokai
set t_Co=256

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

Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat' 
Plugin 'kien/ctrlp.vim'
Plugin 'sjl/gundo.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/ListToggle'

call vundle#end()            " required


filetype plugin indent on 

"options for syntastic"

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_python_checkers=['pep8', 'pylint', 'python']
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_error_symbol = "X"
let g:syntastic_style_error_symbol = ">"
let g:syntastic_warning_symbol = "!"
let g:syntastic_style_warning_symbol = ">"
let g:syntastic_echo_current_error=1
let g:syntastic_enable_balloons = 1
let g:syntastic_auto_jump=1

"Gundo options"

nnoremap <F5> :GundoToggle<CR>

"CtrlP options"
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'

"Powerline stuff"
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

set laststatus=2

YCM 有效,但我无法使用 TAB 在建议之间切换,只能使用向下和向上箭头并使用 Enter 接受。

为什么会这样?是否有其他程序正在使用 TAB 键?

非常感谢您的帮助

问题是由于我的 .vimrc

中的 "set paste" 行

所以,我删除了它,当我想在 vim 中粘贴大块代码时,我只需编写 :set paste 来启用它或 :set nopaste 来禁用它。此切换也可以映射到 f10 或任何键。

通过配置 set paste,您实际上禁用了 所有 映射和缩写。

只有在终端 Vim 中实际粘贴文本时才需要该设置!最好将它绑定到一个键上。由于设置选项时不能使用映射,Vim为此提供了一个特殊选项:

:set pastetoggle=<F10>

进一步评论

由于~/.vimrc是在Vim启动开始时获取的(当传递给它的文件尚未加载时),retab是无效的;放下它。如果你真的想要自动重新缩进打开的文件,你必须为此使用 :autocmd BufRead * retab,但我建议不要那样做。