Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouCompleteme works but can not complete using TAB

I installed YouCompleteMe using vundle. Then installed all plugins and installed YCM using

./install.sh --clang-completer

This is how my vimrc looks:

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 works but I can't switch between the suggestions using TAB, only using Down and Up arrows and accepting with Enter.

Why is happening this? Is another program using the TAB key?

thanks a lot for the help

like image 512
comrad Avatar asked Feb 03 '15 16:02

comrad


2 Answers

By configuring set paste, you're effectively disabling all mappings and abbreviations.

You only need that set when you actually paste text in terminal Vim! It's best to bind this to a key. As mappings cannot be used when the option is set, Vim provides a special option for this:

:set pastetoggle=<F10>

Further commentary

As the ~/.vimrc is sourced at the beginning of Vim startup (when files passed to it haven't yet been loaded), the retab is ineffective; just drop it. If you really want automatic reindenting for opened files, you'd have to employ an :autocmd BufRead * retab for that, but I'd advise against that.

like image 53
Ingo Karkat Avatar answered Oct 20 '22 03:10

Ingo Karkat


The problem was due to the "set paste" line in my .vimrc

so, I removed it, and when I want to paste large blocks of code in vim, I just write :set paste to enable it or :set nopaste to disable it. This toggle can be also mapped to f10 or any key.

like image 40
comrad Avatar answered Oct 20 '22 02:10

comrad