I added a dictionnary with this kind of words :
foo.bar
this.is.a.test
I did :set iskeyword+=.
to have completion works despite dots :
When I type fo<TAB>
--> foo.bar
But I would like to have also this kind of completion :
test<TAB>
--> this.is.a.test
I mean, I won't type always the beginning of a word.
I hope I was clear
Thanks in advance
With insert mode's
<c-x><c-p>
after<c-p>
/<c-n>
you can complete words that follow the previous completion. This assumes that the words appear before together. This means you do not need to add.
to'iskeyword'
(It is better that you don't!).As for completing via the end of words that is probably best done via a custom completion as @Ingo Karkat suggests. However I personally have not come across a need for such a completion.
How to use
<c-x><c-p>
following<c-p>
/<c-n>
test
in the example<c-p>
to start the completion and open the completion menu<c-n>
or<c-p>
(optional)<c-x><c-p>
to complete the next word e.g.is
in the example<c-n>
or<c-p>
(optional)<c-x><c-p>
and<c-p>
/<c-n>
steps as neededSo all together:
test<c-p><c-x><c-p><c-x><c-p><c-x><c-p>
will yieldthis.is.a.test
.Conclusion
Using
<c-x><c-p>
is tricky to explain but much easier to understand after trying it a few times. Trust me it is worth it. You can also do similar tricks with whole line completion, i.e.<c-x><c-l>
. Do yourself a favor and just read all of:h ins-completion
you will be better for it.Aside about using
<tab>
for completionVim offers various completion options. e.g whole line completion via
<c-x><c-l>
, tags:<c-x><c-]>
, filename:<c-x><c-f>
, and more. Often using a clever<tab>
mapping or plugin like SuperTab for completion hides these other completion modes by making them feel less familiar. Note: SuperTab is/was notorious for causing conflicts or bad behavior.For more help see: