[vim/vim] add TextPutPre and TextPutPost autocommands (PR #20144)

19 views
Skip to first unread message

Foxe Chen

unread,
May 5, 2026, 1:48:53 PM (2 days ago) May 5
to vim/vim, Subscribed

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

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

Commit Summary

  • a446430 add TextPutPre and TextPutPost

File Changes

(9 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144@github.com>

Foxe Chen

unread,
May 5, 2026, 1:55:10 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • ebf11f0 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/a4464305b840eba5fa5243da656ef122979045df/after/ebf11f09b1df9e35cad3a77926c5e2c9594c455d@github.com>

Foxe Chen

unread,
May 5, 2026, 1:56:50 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 4fc08d1 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/ebf11f09b1df9e35cad3a77926c5e2c9594c455d/after/4fc08d1ec922a7cd7f6f0cedf403f7c1ad24f882@github.com>

Foxe Chen

unread,
May 5, 2026, 1:58:39 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • cc17f8e add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/4fc08d1ec922a7cd7f6f0cedf403f7c1ad24f882/after/cc17f8ed8da38071e5ec02b0da3d64893ba9dd63@github.com>

Foxe Chen

unread,
May 5, 2026, 2:00:52 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 6df9c4d add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Foxe Chen

unread,
May 5, 2026, 2:01:49 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 86c48b1 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/6df9c4dd008ea4715f157004c52154ff454abff9/after/86c48b163de9ce446c3096259da3006656ffd4af@github.com>

Foxe Chen

unread,
May 5, 2026, 2:10:01 PM (2 days ago) May 5
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#20144)

Heres a script for highlighted put (adapted from hlyank plugin)

vim9script

def HighlightedPut()
    var hlgroup = get(g:, "hlput_hlgroup", "IncSearch")
    var duration = min([get(g:, "hlput_duration", 300), 3000])

    var [beg, end] = [getpos("'["), getpos("']")]
    var type = v:event.regtype ?? 'v'
    var pos = getregionpos(beg, end, {type: type, exclusive: false})

    var m = matchaddpos(hlgroup, pos->mapnew((_, v) => {
        var col_beg = v[0][2] + v[0][3]
        var col_end = v[1][2] + v[1][3] + 1
        return [v[0][1], col_beg, col_end - col_beg]
    }))
    var winid = win_getid()
    timer_start(duration, (_) => {
        if winbufnr(winid) != -1
            m->matchdelete(winid)
        endif
    })

enddef

augroup hlput
    autocmd!
    autocmd TextPutPost * HighlightedPut()
augroup END


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Foxe Chen

unread,
May 5, 2026, 5:23:33 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • bd64305 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/86c48b163de9ce446c3096259da3006656ffd4af/after/bd643052710837159b0dd6a6bdce7648afcfb70a@github.com>

Foxe Chen

unread,
May 5, 2026, 6:58:50 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 5bc4209 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Foxe Chen

unread,
May 5, 2026, 7:00:16 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 0867027 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/5bc4209356ee26af5c67f31cebf865033a650d6f/after/0867027b63267ac79628834881a7ca3f6f7010af@github.com>

zeertzjq

unread,
May 5, 2026, 7:13:04 PM (2 days ago) May 5
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/testdir/test_autocmd.vim:

> @@ -5967,4 +5967,97 @@ func Test_autocmd_add_secure()
   call assert_fails('sandbox call autocmd_delete([{"event": "BufRead"}])', 'E48:')
 endfunc
 
+func Test_TextPostX()
⬇️ Suggested change
-func Test_TextPostX()
+func Test_TextPutX()


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

zeertzjq

unread,
May 5, 2026, 9:14:15 PM (2 days ago) May 5
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/register.c:

> +    // register type
+    switch (get_reg_type(regname, &reglen))
+    {
+	case MLINE:
+	    buf[0] = 'V';
+	    buf[1] = NUL;
+	    buflen = 1;
+	    break;
+	case MCHAR:
+	    buf[0] = 'v';
+	    buf[1] = NUL;
+	    buflen = 1;
+	    break;
+	case MBLOCK:
+	    buflen = vim_snprintf_safelen((char *)buf, sizeof(buf),
+		"%c%ld", Ctrl_V, reglen + 1);
+	    break;
+	default:
+	    buf[0] = NUL;
+	    buflen = 0;
+	    break;
+    }

This code is the same as yank_do_autocmd(). I think it should be deduplicated.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Foxe Chen

unread,
May 5, 2026, 10:33:11 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 51d9a95 add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/0867027b63267ac79628834881a7ca3f6f7010af/after/51d9a95f220da8018adde173d07de25a620aec08@github.com>

Foxe Chen

unread,
May 5, 2026, 10:47:25 PM (2 days ago) May 5
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 60ab75c add TextPutPre and TextPutPost


View it on GitHub or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20144/before/51d9a95f220da8018adde173d07de25a620aec08/after/60ab75c3a2835fe162b6c99bf1fb39662b3c3621@github.com>

Christian Brabandt

unread,
3:18 PM (5 hours ago) 3:18 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20144)

Thanks. Does this handle arbitrary complex content from e.g. the expression register?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Foxe Chen

unread,
3:21 PM (5 hours ago) 3:21 PM
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#20144)

Thanks. Does this handle arbitrary complex content from e.g. the expression register?

Well the autocommands trigger for the expression register, however you cannot set the register contents before it is put, since the expression register + the other special registers don't have a yankreg_T associated with them.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Reply all
Reply to author
Forward
0 new messages