Dictionary Completion of Capitalized Words

17 views
Skip to first unread message

Gary Johnson

unread,
Mar 4, 2022, 2:30:42 AM3/4/22
to vim...@googlegroups.com
Typing part of a word, then using Ctrl-X Ctrl-K to complete the word
from entries in a dictionary works fine as long as the word (not
a proper noun) is all lower case. But when a word that is lower
case in the dictionary is capitalized when typed, as at the start of
a sentence or in a title, completion from the dictionary fails.

Is there a way to have Ctrl-X Ctrl-K complete a capitalized word
even though it is not capitalized in the dictionary?

Example:

cornu<C-X><C-K> expands to cornucopia (or cornucopias), but
Cornu<C-X><C-K> results in E486 Pattern not found.

I'm using Vim 8.2.4127 in a terminal on Linux.

Regards,
Gary

Bram Moolenaar

unread,
Mar 4, 2022, 4:55:48 AM3/4/22
to vim...@googlegroups.com, Gary Johnson
You can set 'ignorecase' to find matches. It's not clever though, it
will then remove the capital letter.

--
hundred-and-one symptoms of being an internet addict:
156. You forget your friend's name but not her e-mail address.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Gary Johnson

unread,
Mar 4, 2022, 11:18:07 AM3/4/22
to vim...@googlegroups.com
On 2022-03-04, Bram Moolenaar wrote:
> Gary Johnson wrote:
>
> > Typing part of a word, then using Ctrl-X Ctrl-K to complete the word
> > from entries in a dictionary works fine as long as the word (not
> > a proper noun) is all lower case. But when a word that is lower
> > case in the dictionary is capitalized when typed, as at the start of
> > a sentence or in a title, completion from the dictionary fails.
> >
> > Is there a way to have Ctrl-X Ctrl-K complete a capitalized word
> > even though it is not capitalized in the dictionary?
> >
> > Example:
> >
> > cornu<C-X><C-K> expands to cornucopia (or cornucopias), but
> > Cornu<C-X><C-K> results in E486 Pattern not found.
> >
> > I'm using Vim 8.2.4127 in a terminal on Linux.
>
> You can set 'ignorecase' to find matches. It's not clever though, it
> will then remove the capital letter.

That's an improvement over what I had been doing. Thank you.

I always have 'ignorecase' set, but I also have 'smartcase' set.
I know the following has limitations, but it helps. I'll have to
see if it interferes too much with other completions.

au InsertEnter * set nosmartcase
au InsertLeave * set smartcase

Regards,
Gary

Bram Moolenaar

unread,
Mar 4, 2022, 11:47:00 AM3/4/22
to vim...@googlegroups.com, Gary Johnson
Using 'smartcase' works halfway a sentence, so that when, for example,
you complete "Ne" the country name "Netherlands" matches, and not words
starting with "ne". But it's different at the start of a sentence. It
would require the smartness of spell checking to detect that. I'm not
sure if we would need to build in support for this, or that it can be
done with a plugin.

--
Send $25.00 for handy leaflet on how to make money by selling leaflets

Lifepillar

unread,
Mar 5, 2022, 8:04:19 AM3/5/22
to vim...@googlegroups.com
On 2022-03-04, Gary Johnson <gary...@spocom.com> wrote:
> On 2022-03-04, Bram Moolenaar wrote:
>> Gary Johnson wrote:
>>
>> > Typing part of a word, then using Ctrl-X Ctrl-K to complete the word
>> > from entries in a dictionary works fine as long as the word (not
>> > a proper noun) is all lower case. But when a word that is lower
>> > case in the dictionary is capitalized when typed, as at the start of
>> > a sentence or in a title, completion from the dictionary fails.
>> >
>> > Is there a way to have Ctrl-X Ctrl-K complete a capitalized word
>> > even though it is not capitalized in the dictionary?
>> >
>> > Example:
>> >
>> > cornu<C-X><C-K> expands to cornucopia (or cornucopias), but
>> > Cornu<C-X><C-K> results in E486 Pattern not found.
>> >
>> > I'm using Vim 8.2.4127 in a terminal on Linux.
>>
>> You can set 'ignorecase' to find matches. It's not clever though, it
>> will then remove the capital letter.
>
> That's an improvement over what I had been doing. Thank you.
>
> I always have 'ignorecase' set, but I also have 'smartcase' set.

Have you tried setting infercase?

Life.

Gary Johnson

unread,
Mar 6, 2022, 12:01:34 PM3/6/22
to vim...@googlegroups.com
On 2022-03-05, Lifepillar wrote:

> Have you tried setting infercase?

No, I hadn't. That seems to do just what I want. Thank you!

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages