[vim/vim] feat: make 'preinsert' work with 'autocomplete' (PR #18213)

55 views
Skip to first unread message

girish

unread,
Sep 5, 2025, 4:49:34 PM (5 days ago) Sep 5
to vim/vim, Subscribed

This change extends Insert mode autocompletion so that "preinsert" behavior of 'completeopt' also
works when 'autocomplete' is enabled.

Try: :set autocomplete completeopt=preinsert. It's quite useful.

See :help 'cot' for more details.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18213

Commit Summary

  • 5edc60c feat: make 'preinsert' work with 'autocomplete'
  • 673bfef Fix test failure
  • 40ab5b7 Merge branch 'vim:master' into preinsert

File Changes

(7 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213@github.com>

girish

unread,
Sep 5, 2025, 5:02:58 PM (5 days ago) Sep 5
to vim/vim, Push

@girishji pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/40ab5b77372d2cb096a504c0ab1f0b2d17a504a9/after/1d95c3005765a149e54066c3ae11690133a291ad@github.com>

girish

unread,
Sep 5, 2025, 5:20:58 PM (5 days ago) Sep 5
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/1d95c3005765a149e54066c3ae11690133a291ad/after/4bde1227bb8a0eb3a7f6c5c5da44d2e4434b5d89@github.com>

Maxim Kim

unread,
Sep 5, 2025, 9:50:25 PM (5 days ago) Sep 5
to vim/vim, Subscribed
habamax left a comment (vim/vim#18213)

Looks like hl-ComplMatchIns is not defined in vim/colorschemes. Is it a new one or I completely overlooked its existence?

image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3260192206@github.com>

girish

unread,
Sep 6, 2025, 1:17:41 AM (5 days ago) Sep 6
to vim/vim, Subscribed
girishji left a comment (vim/vim#18213)

It was already there. I just noticed it was undefined, so I linked it to the Added highlight group.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3260890647@github.com>

girish

unread,
Sep 6, 2025, 2:27:24 AM (4 days ago) Sep 6
to vim/vim, Push

@girishji pushed 1 commit.

  • 1759f6c Add document to show typical usage

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/4bde1227bb8a0eb3a7f6c5c5da44d2e4434b5d89/after/1759f6c8422ac2b78d70b5f4f762381a41e7dc01@github.com>

girish

unread,
Sep 6, 2025, 3:00:36 AM (4 days ago) Sep 6
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/1759f6c8422ac2b78d70b5f4f762381a41e7dc01/after/351861a00f3ac768c5d3e9080fa2187812c55e50@github.com>

girish

unread,
Sep 6, 2025, 9:32:45 AM (4 days ago) Sep 6
to vim/vim, Push

@girishji pushed 1 commit.

  • a865003 Merge branch 'vim:master' into preinsert

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/351861a00f3ac768c5d3e9080fa2187812c55e50/after/a865003d4ed21df23ef3c35d9bca6a04a3e6138a@github.com>

Christian Brabandt

unread,
Sep 6, 2025, 2:00:09 PM (4 days ago) Sep 6
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18213)

Thanks, but this seems to break a few screen-dump tests


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3262830456@github.com>

girish

unread,
Sep 6, 2025, 3:51:04 PM (4 days ago) Sep 6
to vim/vim, Push

@girishji pushed 2 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/a865003d4ed21df23ef3c35d9bca6a04a3e6138a/after/5df7dde1fbd015ccdfa609770e2598d232bde9fb@github.com>

girish

unread,
Sep 6, 2025, 3:55:43 PM (4 days ago) Sep 6
to vim/vim, Subscribed
girishji left a comment (vim/vim#18213)

Thanks, but this seems to break a few screen-dump tests

Thanks, just noticed this. The failures are caused by the highlight group ComplMatchIns, which I had linked incorrectly to another group. That was a mistake. ComplMatchIns isn’t limited to preinsert -- it also highlights the postfix part of the text when selecting from the popup menu.

I am not sure if it would make sense to have a separate highlight group from preinsert. For now, I reverted the changes so as not to hold up this PR.

@habamax I think hl-ComplMatchIns can’t really be used in any colorscheme, because it highlights every match you pick from the menu. That feels quite unusual.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3263169899@github.com>

girish

unread,
Sep 6, 2025, 4:51:26 PM (4 days ago) Sep 6
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/5df7dde1fbd015ccdfa609770e2598d232bde9fb/after/ac41949dbd09d7d5aa55bf9e059408f634f7fad7@github.com>

girish

unread,
Sep 6, 2025, 4:53:24 PM (4 days ago) Sep 6
to vim/vim, Push

@girishji pushed 1 commit.

  • 7b3e644 Merge branch 'vim:master' into preinsert

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/ac41949dbd09d7d5aa55bf9e059408f634f7fad7/after/7b3e6445af35e88a2e55c4b0bce0eeb04b709e05@github.com>

girish

unread,
Sep 7, 2025, 4:39:06 AM (3 days ago) Sep 7
to vim/vim, Push

@girishji pushed 1 commit.

  • 005c9bc Fix test failure (revert previous refactor)

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/7b3e6445af35e88a2e55c4b0bce0eeb04b709e05/after/005c9bc9609d87dfe6461542e224271657611101@github.com>

girish

unread,
Sep 7, 2025, 4:57:10 AM (3 days ago) Sep 7
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/f7bd85dec6b2949208fda21e3393bc13b20b336c/after/e6388d0014ad925d5267099e362aceaf16d3f850@github.com>

girish

unread,
Sep 7, 2025, 5:00:11 AM (3 days ago) Sep 7
to vim/vim, Subscribed
girishji left a comment (vim/vim#18213)

Added a new highlight group hl-PreInsert. Using hl-ComplMatchIns for both purposes prevented setting distinct default colors for pre-inserted text. Currently applies only to 'autocomplete'.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3263602084@github.com>

girish

unread,
Sep 7, 2025, 11:04:13 AM (3 days ago) Sep 7
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/e6388d0014ad925d5267099e362aceaf16d3f850/after/b8cbe3f0b29cb3fff706576edd8e40230dc47056@github.com>

girish

unread,
Sep 8, 2025, 10:28:44 AM (2 days ago) Sep 8
to vim/vim, Push

@girishji pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/before/b8cbe3f0b29cb3fff706576edd8e40230dc47056/after/6d64b4b2556aa956fc59df1ba8c06c5eaddc89f8@github.com>

Christian Brabandt

unread,
Sep 8, 2025, 3:16:31 PM (2 days ago) Sep 8
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18213)

thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3267617064@github.com>

Christian Brabandt

unread,
Sep 8, 2025, 3:26:23 PM (2 days ago) Sep 8
to vim/vim, Subscribed

Closed #18213 via fa6fd41.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/issue_event/19572297108@github.com>

girish

unread,
Sep 8, 2025, 3:54:22 PM (2 days ago) Sep 8
to vim/vim, Subscribed
girishji left a comment (vim/vim#18213)

Thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3267727748@github.com>

Maxim Kim

unread,
Sep 8, 2025, 7:53:14 PM (2 days ago) Sep 8
to vim/vim, Subscribed
habamax left a comment (vim/vim#18213)

@lifepillar, there is new PreInsert hl, you may want to add it to coloremplate.

image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3268375947@github.com>

Justin M. Keyes

unread,
Sep 8, 2025, 11:50:45 PM (2 days ago) Sep 8
to vim/vim, Subscribed
justinmk left a comment (vim/vim#18213)

Added a new highlight group hl-PreInsert. Using hl-ComplMatchIns

Why is the new hl group named PreInsert, instead of something like ComplPreIns ? Can Vim please pick a convention and stick with it?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3268766266@github.com>

Christian Brabandt

unread,
Sep 9, 2025, 1:46:50 AM (yesterday) Sep 9
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18213)

It should be ComplMatchPreIns no? We can rename it


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3268960715@github.com>

girish

unread,
Sep 9, 2025, 2:00:51 AM (yesterday) Sep 9
to vim/vim, Subscribed
girishji left a comment (vim/vim#18213)

I wasn’t aware there was a convention. I chose what felt the most intuitive and readable. When I first saw hl-ComplMatchIns, it looked like a jumble of letters I couldn’t immediately connect to anything. If a convention is already established, I don’t mind following it, but it feels odd to replace a meaningful tag with something that looks cryptic.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3268990319@github.com>

Maxim Kim

unread,
Sep 9, 2025, 2:05:56 AM (yesterday) Sep 9
to vim/vim, Subscribed
habamax left a comment (vim/vim#18213)

There seems to be no convention. I personally like PreInsert more.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3269002857@github.com>

Maxim Kim

unread,
Sep 9, 2025, 2:14:52 AM (yesterday) Sep 9
to vim/vim, Subscribed
habamax left a comment (vim/vim#18213)

@chrisbra do you go to neovim github questioning what neovim does?

The message could have been a tiny bit more polite.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3269026035@github.com>

Christian Brabandt

unread,
Sep 9, 2025, 3:10:03 PM (22 hours ago) Sep 9
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18213)

The message could have been a tiny bit more polite.

agree.

if a convention is already established, I don’t mind following it, but it feels odd to replace a meaningful tag with something that looks cryptic.

Well, we only have a single highlight group for completion: ComplMatchIns so it seems we have a precedent for other related highlighting groups. So if there is a chance we will have more additional related highlighting groups related to completion feature, I think this would make sense to have a consistent naming.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3271955846@github.com>

girish

unread,
Sep 9, 2025, 4:24:13 PM (21 hours ago) Sep 9
to vim/vim, Subscribed
girishji left a comment (vim/vim#18213)

The doc is incorrect:

ComplMatchIns   Matched text of the currently inserted completion.

This highlight group applies to the unmatched portion of the completion (the suffix). Consider renaming it to something like InsertedSuffix, CompletionSuffix, PostfixText, etc. Current name conveys the opposite meaning of what it is doing.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3272152168@github.com>

Christian Brabandt

unread,
2:37 AM (11 hours ago) 2:37 AM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18213)

So this comes from patch 6a38aff (v9.1.0936). We could consider renaming it. But I think this is too late already


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3273507314@github.com>

Maxim Kim

unread,
3:29 AM (10 hours ago) 3:29 AM
to vim/vim, Subscribed
habamax left a comment (vim/vim#18213)

According to the document you have recently authored, it is not too late :)

FWIW, it is not in any of built-in colorschemes.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3273682653@github.com>

Christian Brabandt

unread,
3:47 AM (10 hours ago) 3:47 AM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18213)

yep I know. in that case what would be a good naming convention? Something that would also apply for PreInsert?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3273743644@github.com>

Maxim Kim

unread,
4:02 AM (9 hours ago) 4:02 AM
to vim/vim, Subscribed
habamax left a comment (vim/vim#18213)

in that case what would be a good naming convention? Something that would also apply for PreInsert?

Should we have a prefix for the group of 2 (as of now) highlight groups?

  • CompletePreInsert, CoPreInsert, CtePreInsert, ...
  • CompleteMatchInsert, CoMatchInsert, CteMatchInsert, ... or CompleteSuffix, CompleteMatchSuffix, CoMatchSuffix, CteMatchSuffix


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3273794060@github.com>

Shane-XB-Qian

unread,
4:50 AM (9 hours ago) 4:50 AM
to vim/vim, Subscribed
Shane-XB-Qian left a comment (vim/vim#18213)
> According to the document you have recently authored, it is not too late :)
>
> FWIW, it is not in any of built-in colorschemes.

but it maybe in some user's vimrc already, (supposed you meant the 'policy' new added into develop.txt),
as usually in the past it was allowed maximal 1 week, minimal 1 day, i may think the 'policy' should keep that way.

now this 'CompMatchIns' had been over many weeks, i think better be keep it is now;
as for 'preinsert', how about 'ComplPreIns' or 'ComplMatchPreIns'?

--
shane.xb.qian


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18213/c3273965662@github.com>

Reply all
Reply to author
Forward
0 new messages