Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On VSC, can I copy/paste folded codes and keep them folded?

For example, if I fold code

div
something here
/div

into

div...
/div

And copy and paste the folded code, the result appears as unfolded code lines. Is there any way to keep them folded when paste? It looks like it is default on pycharm. :(

like image 822
Steven Jang Avatar asked Dec 30 '25 16:12

Steven Jang


2 Answers

Here is the way:

Step1: Open your code in vscode

Step2: Cmd + Shift + P (Mac) or Ctrl+Shift+P (Windows) to open Command Palette, search and select Fold All

Step3: Toolbar -> Selection -> Column Selection Mode

Step4: Column select all the code, copy and paste, done!

like image 93
Shiming Avatar answered Jan 02 '26 09:01

Shiming


No, see [folding] retain folded state on copy/paste . I do not think it is language-specific but happens to all languages.

It is on the Backlog since 2016, and not many votes... so upvote it.

like image 23
Mark Avatar answered Jan 02 '26 08:01

Mark



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!