Bram Moolenaar wrote:
Vincent Linsong wrote:
This is by design. Some people mentioned that when using the longest
common string the first entry should not be selected. Now you can use
CTRL-N to select the first entry. Previously you would need to do
CTRL-N CTRL-P to get the first entry.
I use the omnicompletion like this:
I set completeopt=menu,preview,longest . Now consider I input some
characters of a function's name, for example, the function's name is
'helloWorld' and I input 'hel'. I am not glad to remember the exact
function name, so I invoke omnicompletion by <C-X><C-O>, then I know
what is the exact name of the function, instead of press <C-N> or <C-P>
multiple times to select it from the menu, I choose to input more
characters and when function's name becomes the top entry on the menu, I
will press <C-Y> to accept it. I think this way is very convenient and I
know many intelligence like tools works in this way.
If others have enough reason to change the behavior, would you like
to add a new option to make two ways work ? Thanks a lot!
I think the current behavior is best for most people. For you, instead
of pressing CTRL-Y you can use CTRL-N and continue typing, that normally
stops completion.
If I press CTRL-N, then what I inputed will be replaced with the first
entry of the completion menu, but that is not what I want.
I don't get it.
Sorry, my words is a little confusing.
You type characters until the function you were looking
for is the first match. Then CTRL-N will select that match and you're
done.
In fact, I input more characters until the function I am looking for is
the the first match, under this case, I want to select the first match
and make the menu disappear(why? because to my impression, the
completion is not done until I select some entry and the completion menu
disappears). But now I have to press CTRL-N CTRL-E to do so, that is not
very convenient.
Yes, I can make a map make it easier, for example I have the following
match:
if exists('*pumvisible')
inoremap <Enter> <C-R>=pumvisible() ? "\<lt>C-y>" :
"\<lt>Enter>"<CR>
endif
It works very well under vim7d Beta with
completeopt=menu,preview,longest, this map just makes Enter as the
confirm key instead of <C-Y> since I am tempted to use Enter as the
confirm key. It works in the following two cases:
case 1: I input charactes and when the first match is what I want, I
just press Enter to confirm, what I inputed is completed and the
completion menu disappear
case 2: I use CTRL-N or CTRL-P to change the highlighted entry to
the one I want, then I press Enter to confirm.
But in vim7f Beta, since the first match has not been highlighted
any more, the map does not work in case 1. I can modify it a little to
make it work:
if exists('*pumvisible')
inoremap <Enter> <C-R>=pumvisible() ? "\<lt>C-n>\<lt>C-y>" :
"\<lt>Enter>"<CR>
endif
But it will not work in case 2. I can not work out a way to make it
work in case 1 and case 2.
I know what is the reason of the change between vim7f and vim7d and I
think it is very reasonable. But I still suggest there should be an
option to highlight the first match of completion menu.
Thanks.
BR
Vincent
There is a conflict between saying that the top entry of the menu is the
one you want and CTRL-N not getting what you want.