janus icon indicating copy to clipboard operation
janus copied to clipboard

Autocomplete with tab and enter to select inserts new line

Open shwoodard opened this issue 10 years ago • 4 comments

STR: type fragment of matched word and press tab and then press enter on selected option

Actual: the autocomplete selects the option and inserts a new line Expected: the autocomplete selects the option and does not insert a new line

shwoodard avatar Jan 22 '15 18:01 shwoodard

I've discovered that esc works. Should we close this and just call this the new behavior?

shwoodard avatar Feb 01 '15 17:02 shwoodard

I agree. I would say just about anybody would expect this behavior.

I believe this is the default behavior of Vim's built-in autocomplete, however. There are some resources that discuss this issue: http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE https://unix.stackexchange.com/questions/162528/select-an-item-in-vim-autocomplete-list-without-inserting-line-break

I'm going to try adding this Vimtip to my rc and see how that goes.

inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"

dechimp avatar Jul 07 '15 04:07 dechimp

I just learned that the above command seems to interfere with other things, like auto-insertion helpers for Ruby, as pointed out by chrisnicola: https://github.com/spf13/spf13-vim/issues/280

dechimp avatar Jul 07 '15 16:07 dechimp

I second this issue. This is not how I expect it to work. There should not be an auto-newline added. The tip provided by dechimp seems to work great for me, so far.. I now have in my vimrc:

"ENABLES AUTOCOMPLETE Plugin 'ervandew/supertab' inoremap inoremap <CR> pumvisible() ? "<C-y>" : "<C-g>u<CR>"

tommyjcarpenter avatar Dec 11 '15 18:12 tommyjcarpenter