[vim/vim] Add OSC52 plugin for clipboard support (PR #18575)

43 views
Skip to first unread message

Foxe Chen

unread,
Oct 14, 2025, 10:23:14 PM (6 days ago) Oct 14
to vim/vim, Subscribed

WIP


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

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

Commit Summary

File Changes

(1 file)

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/18575@github.com>

Maxim Kim

unread,
Oct 14, 2025, 10:28:29 PM (6 days ago) Oct 14
to vim/vim, Subscribed
habamax left a comment (vim/vim#18575)

Could you consider making it optional?

With location in ~/pack/dist/opt/osc52/plugin/... we should be able to enable it with packadd osc52.


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/18575/c3404280688@github.com>

Foxe Chen

unread,
Oct 14, 2025, 10:45:15 PM (6 days ago) Oct 14
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18575)

Could you consider making it optional?

With location in ~/pack/dist/opt/osc52/plugin/... we should be able to enable it with packadd osc52.

Yes I planned on doing that, I'll change it later


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/18575/c3404307670@github.com>

Foxe Chen

unread,
Oct 14, 2025, 11:08:13 PM (6 days ago) Oct 14
to vim/vim, Push

@64-bitman 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/18575/before/9ed55930fdfd0fc470b9b55f99435a833449565e/after/432ebdbb5d27cacb54b8ad9fa344a8af94e74ae0@github.com>

Foxe Chen

unread,
Oct 16, 2025, 9:27:40 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 3 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/432ebdbb5d27cacb54b8ad9fa344a8af94e74ae0/after/0e90f6d9c44a38fe68511c2ee16f14cdc2eb5492@github.com>

Foxe Chen

unread,
Oct 16, 2025, 9:29:41 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/0e90f6d9c44a38fe68511c2ee16f14cdc2eb5492/after/da6afc846cd4f62d61210e794398ea944ac5dd27@github.com>

Foxe Chen

unread,
Oct 16, 2025, 9:31:11 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/da6afc846cd4f62d61210e794398ea944ac5dd27/after/1978aceda8ebaed972c0abbc79cc1e527797864b@github.com>

Foxe Chen

unread,
Oct 16, 2025, 9:38:30 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/1978aceda8ebaed972c0abbc79cc1e527797864b/after/f397272f7d96f93ae24ebb0e8ddb84debe0ba8dd@github.com>

Foxe Chen

unread,
Oct 16, 2025, 10:28:06 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/f397272f7d96f93ae24ebb0e8ddb84debe0ba8dd/after/2b42e574c875f4ac675fbc889037e2cfbae7a405@github.com>

Foxe Chen

unread,
Oct 16, 2025, 10:29:38 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/2b42e574c875f4ac675fbc889037e2cfbae7a405/after/43862cf46d2f60b05976c0c4d84c5456003a9b08@github.com>

Foxe Chen

unread,
Oct 16, 2025, 10:30:21 PM (4 days ago) Oct 16
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/43862cf46d2f60b05976c0c4d84c5456003a9b08/after/4b98bdbbf73786cdf60f0bf9609c7c63b1a75de1@github.com>

Foxe Chen

unread,
Oct 16, 2025, 10:32:31 PM (4 days ago) Oct 16
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18575)

Could anyone test in MacOS? I have added documentation on how to use


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/18575/c3413542974@github.com>

Foxe Chen

unread,
Oct 17, 2025, 7:50:56 AM (4 days ago) Oct 17
to vim/vim, Push

@64-bitman pushed 1 commit.

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

Foxe Chen

unread,
Oct 17, 2025, 5:56:46 PM (3 days ago) Oct 17
to vim/vim, Push

@64-bitman pushed 6 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/af1c7cedd89f25a97420c3cacf8461738c4c4985/after/63bb682e0eb30ac32f43760e9f3e26bc48374293@github.com>

Foxe Chen

unread,
Oct 18, 2025, 12:58:36 AM (3 days ago) Oct 18
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 3b2c050 make available function be autoloaded

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/63bb682e0eb30ac32f43760e9f3e26bc48374293/after/3b2c0500ba470e62ca124c29cf2000952eec882e@github.com>

Foxe Chen

unread,
Oct 18, 2025, 1:00:59 AM (3 days ago) Oct 18
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18575)

I think this is ready. I didn't add tests because this plugin is very simple anyways + I can't figure out a way to actually test the plugin


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/18575/c3417810265@github.com>

Christian Brabandt

unread,
Oct 18, 2025, 10:44:05 AM (3 days ago) Oct 18
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18575)

did someone try it out? Ping @peterwu who requested this functionality in #14995


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/18575/c3418477171@github.com>

Peter Wu

unread,
Oct 18, 2025, 12:14:12 PM (3 days ago) Oct 18
to vim/vim, Subscribed
peterwu left a comment (vim/vim#18575)

I tested on my MacBook and it didn't seem to work.

  1. compiled from https://github.com/64-bitman/vim/tree/osc52_plugin
  2. make
  3. make install
  4. ~/.vimrc
packadd osc52
set clipmethod^=osc52

This will print ^[[?1;2c when launching vim.
5. ~/.vimrc

packadd osc52
g:osc52_force_avail = true
set clipmethod^=osc52

This doesn't print anything when launching vim.

  1. If I do "+yy, the content is not copied to the + register.
  2. If I do "*yy, thee content is copied to the * register but not available in the system clipboard.
  3. The same happens to "*p as it does not paste what's in the system clipboard to the vim session.


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/18575/c3418621208@github.com>

Foxe Chen

unread,
Oct 18, 2025, 2:34:52 PM (3 days ago) Oct 18
to vim/vim, Push

@64-bitman pushed 2 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/3b2c0500ba470e62ca124c29cf2000952eec882e/after/7bfda387af232b65cd7a1b773fab393b128faad5@github.com>

Foxe Chen

unread,
Oct 18, 2025, 2:35:02 PM (3 days ago) Oct 18
to vim/vim, Push

@64-bitman pushed 0 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/7bfda387af232b65cd7a1b773fab393b128faad5/after/3b2c0500ba470e62ca124c29cf2000952eec882e@github.com>

Foxe Chen

unread,
Oct 18, 2025, 2:43:53 PM (3 days ago) Oct 18
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/3b2c0500ba470e62ca124c29cf2000952eec882e/after/ec52fc8e8379372b16f066ceeecf2ff57229cf94@github.com>

Foxe Chen

unread,
Oct 18, 2025, 2:47:30 PM (3 days ago) Oct 18
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/ec52fc8e8379372b16f066ceeecf2ff57229cf94/after/0315858bedd890a5b3d5fd48910e8cb703640fd8@github.com>

Foxe Chen

unread,
Oct 18, 2025, 2:48:15 PM (3 days ago) Oct 18
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18575/before/0315858bedd890a5b3d5fd48910e8cb703640fd8/after/0f0c30f74d3c917a3602ff2367ac9e325c9b05c2@github.com>

Foxe Chen

unread,
Oct 18, 2025, 2:54:24 PM (3 days ago) Oct 18
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18575)

In all cases, ommiting g:osc52_force_avail = true results in some escape chars printed on the terminal before vim shows up.

That is likely from Vim trying to detect if the terminal supports OSC 52, I've made it now that is prints a message while waiting for a response (which may never come)

Ghostty prints ^[[?62;22;52c while kitty prints ^[[?62;52c. And when this happens, the OSC52 function does not work.

Can you elaborate on this? The plugin should match the '52' in those responses and enable the osc52 functionality. Or is it just printing characters to the screen? If so can you try the latest commit?

The following is for my test on Terminal app but the same steps were performed for Ghostty and kitty.

  1. compiled from https://github.com/64-bitman/vim/tree/osc52_plugin
  2. make
  3. make install
  4. ~/.vimrc
packadd osc52
set clipmethod^=osc52

This will print ^[[?1;2c when launching vim. 5. ~/.vimrc

packadd osc52
g:osc52_force_avail = true
set clipmethod^=osc52

This doesn't print anything when launching vim.

  1. If I do "+yy, the content is not copied to the + register.
  2. If I do "*yy, thee content is copied to the * register but not available in the system clipboard.
  3. The same happens to "*p as it does not paste what's in the system clipboard to the vim session.

It seems that that the MacOS default terminal does not support OSC52, could you show the value of v:clipmethod? It looks like iTerm supports OSC 52 so could you try that? 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/18575/c3418739668@github.com>

Peter Wu

unread,
Oct 18, 2025, 4:20:18 PM (3 days ago) Oct 18
to vim/vim, Subscribed
peterwu left a comment (vim/vim#18575)

I did a git pull off the osc52_plugin, recompiled and discovered a few things.

If g:osc52_force_avail = true is not set in vimrc, now it prints something like this:

Waiting for OSC 52 response...^[[?64;1;2;4;6;17;18;21;22c

By that, I mean:

  1. put the following in vimrc
packadd osc52
set clipmethod^=osc52
  1. run vim
  2. vim will print these characters right after like this:
$ vim
Waiting for OSC 52 response...^[[?64;1;2;4;6;17;18;21;22c
  1. at this time, the vim session seems to wait for ever until I hit ENTER
  2. after I hit ENTER, the main vim session shows up but at the bottom it displays a similar message:
~                type  :help version9<Enter>   for version infoWaiting for OSC 52 response...^[[?64;1;2;4;6;17;18;21;22c

that's right: the Waiting message follows directly after the initial startup message
6. at this stage, I can't fire vim commands, such as i, d, y, p, etc. These keys will be printed right after the Waiting message
7. This stops when I hit ENTER again
8. Now, I use the vim session as usual

So, imo, the updated commits made things even worse. Before the chars were displayed at step3 but after I hit ENTER, it let me use vim without step 6.

I also tested iTerm2, v3.6.4. If I followed the instructions to disable clipboard access, I can copy content to clipboard but cannot paste content from clipboard. I'm not familar with iTerm2 so maybe I didn't figure out a setting somewhere to enable paste.

Another thing that I noticed:

On my MacBook Air running 26.0.1, I was able to compile from source without any issues;
On my MacBook Pro running 26.0.1, I couldn't compile the https://github.com/64-bitman/vim.git (neither master nor osc52_plugin) but I could compile https://github.com/vim/vim.git with no issues.


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/18575/c3418791098@github.com>

Yamagi

unread,
Oct 18, 2025, 4:21:52 PM (3 days ago) Oct 18
to vim/vim, Subscribed
Yamagi left a comment (vim/vim#18575)

I gave it a try with Alacritty under Linux and both copy and paste are working fine. Just a small nitpicks: I'm also seeing Waiting for OSC 52 response...^[[?6c. The message added in the last commits makes clear what's going on, but what about adding a hint that the response may never come and pressing Return forces Vim to continue? Also, why do I need press Return four times until Vim starts? :messages is empty.


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/18575/c3418791831@github.com>

alex-huff

unread,
Oct 19, 2025, 1:14:36 PM (2 days ago) Oct 19
to vim/vim, Subscribed
alex-huff left a comment (vim/vim#18575)

I experience the same issues. However, if I manually run

:packadd osc52
:set clipmethod^=osc52

after vim has already loaded it works as expected. It seems the primary device attributes event isn't get triggered specifically in the context that .vimrc is loaded, causing Available() to hang.

One more thing. When pasting a clipboard that has no newlines, it seems a newline is inserted at the end.


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/18575/c3419817171@github.com>

Reply all
Reply to author
Forward
0 new messages