Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect copy and cut actions in visual studio code extensions?

I develop a vscode extension.
I would like to decect user action for copy and cut on the editor.

I checked API reference, but I could not find the method.

How can I do this in extensions with typescript ?

like image 557
t-yng Avatar asked Dec 05 '25 07:12

t-yng


1 Answers

You are right, there is no API for that, and by VSCode Approach to Extensibility, you may be out of luck.

I had tried to replace the original Copy and Cut commands, but ended up creating new commands and adding instructions to the user to replace the keybindings, when I created my Copy Word in Cursor extension. I had issues because VSCode itself does not publish a Clipboard object (compared to Atom), so I had to do myself, using node-copy-paste package.

Unless they have changed its idea (try to open an issue on VSCode repo), you should create new Copy and Cut commands to accomplish what your extension needs to do.


like image 96
alefragnani Avatar answered Dec 07 '25 22:12

alefragnani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!