Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy & paste folded text in Visual Studio Code

Given the following text

Node1_L1
  Node1_L2
  Node2_L2
Node2_L1
  Node3_L2
    Node1_L3
    Node2_L3
  Node4_L2
    Node3_L3
    Node4_L3
Node3_L1
  Node5_L2
  Node6_L2  

I can use vscode's built-in folding feature to fold it to look like so

+ Node1_L1
  Node2_L1
+   Node3_L2
+   Node4_L2
  Node3_L1
    Node5_L2
    Node6_L2

but when I now select the folded text and copy & paste it then it actually grabbed all text - also the hidden one. The result of copy & paste of the first 4 lines of the folded text above would therefore be

Node1_L1
  Node1_L2
  Node2_L2
Node2_L1
  Node3_L2
    Node1_L3
    Node2_L3
  Node4_L2

whereas I would like to have

Node1_L1
Node2_L1
  Node3_L2
  Node4_L2  

Hope that makes sense and someone knows a way to do it. Thanks!

like image 441
NoaHammer Avatar asked Aug 26 '16 18:08

NoaHammer


People also ask

What do you mean copy?

1 : an imitation, transcript, or reproduction of an original work (such as a letter, a painting, a table, or a dress) 2 : one of a series of especially mechanical reproductions of an original impression also : an individual example of such a reproduction.

What does copy mean in writing?

Broadly defined, copy is text within a publication or composition. It is in contrast to any graphic or pictorial aspects of a publication, article, or another kind of composition. Alternate definition: A reproduction of an original work.

What does it mean to say do you copy?

“Do you copy' is a phrase used in military and other important radio communications, and comes from the fact that the recipient would write down (a copy of) the message so that it could be carried to, and read by, the superior officer.


2 Answers

Maybe there is another way of doing it but a workaround seems to be using block selection with multiple cursors - see the GIF

Block selection to copy only top level folding text

like image 73
DAXaholic Avatar answered Oct 14 '22 18:10

DAXaholic


If the selection doesn't include the new line and carriage return, folded content will not be copied.

The selection must go to the start of the next line to select the folded text ( hidden text )

enter image description here

https://github.com/Microsoft/vscode/issues/41922#issuecomment-359368290

The op actually wants to select 'unfolded' text ignoring the folded text so they need to use a multi-line select where each selection will span a single line

like image 1
ta32 Avatar answered Oct 14 '22 20:10

ta32