22

When there are multiple complete suggestions from Vim plugin YouCompleteMe, how do I accept the one I want ?

What I currently do is pressing Esc key, I just want to know if I got it right.

Xavier T.
  • 40,509
  • 10
  • 68
  • 97
Ask and Learn
  • 8,661
  • 8
  • 37
  • 43
  • 1
    See also [How to select SuperTab completion suggestion without creating new line?](http://stackoverflow.com/q/7870086). – glts Nov 07 '13 at 18:54

4 Answers4

32

To accept the current insert completion entry use <c-y>. Think of it as "yes".

For more help see:

:h complete_ctrl-y
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
12

Usually with Ctrl + Y (yes); read up :help popupmenu-keys.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
11

Ctrl-Y is default, but you can add other key bindings by adding this line to your .vimrc:

let g:ycm_key_list_stop_completion = ['<C-y>', '<CR>']

In this ^ example, you can use either Ctrl-Y or Enter to accept the completion and free up the cursor.

0x000bff
  • 111
  • 2
  • 6
-6

For some reason, I think that you didn't really read the documentation and/or the README:

When the user sees a useful completion string being offered, they press the TAB key to accept it. This inserts the completion string. Repeated presses of the TAB key cycle through the offered completions.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • 2
    I read that, and it says "repeated presses of the TAB key cycle through the offered completions" It did not say how to pick one if there are more than one. – Ask and Learn Nov 07 '13 at 23:00
  • If you want the third suggestion you hit tab 2 times: the word you wanted is inserted so you are supposed to simply continue your typing. – romainl Nov 07 '13 at 23:35
  • 2
    @romainl But what if I just finished typing as the word is completed? What I do is hit the Esc key and the suggestion is gone. Instead of the completed word I have there only the letters that I typed. What is the proper way of accepting the suggestion and leaving the instert mode instead of just pressing Esc? Or is it possible to accept the word with Esc too? – Hermes Feb 20 '14 at 16:12
  • Actually, using `TAB` and `SHIFT+TAB` is a good solution for traversing between suggestions and releasing and continuing to code. awesome, thanks. I leave an upvote. – AmerllicA Mar 13 '20 at 09:35