Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy the code text from MS Visual Studio and keeping the source color and formatting

I used to copy the text of my C# code in a word document to have a backup of my progress. Previously the color of the codes (blue, black, green) was kept when I paste it in any text editor program (MS word, WordPad ...). Recently it is not so. The format of the text (indentations) is kept but the color unfortunately is just black. That helped me a lot to have previous version of my code on another monitor. The codes are displayed just normal in Microsoft Visual Studio but the color is lost when I copy and paste it anywhere else. (I have checked the paste setting of MS word and they are set to keep the formatting of the source. The problem shouldn't be there.)

I use Microsoft Visual Studio Professional 2019.


Edit and answer:

The problem was that although the "cope rich text on copy/cut" option was checked, my code exceeded the maximum character count for this property. It was solved by changing the "Max Length" to a very big number. Default is 10240 and I added three more zeros.

Therefore the path to the solution is:

Tools --> options --> Text Editor --> Advanced --> Copy rich text on copy/cut (checked) --> Max Length (a very big number)

enter image description here

like image 699
Iraj Avatar asked Sep 05 '25 02:09

Iraj


1 Answers

You need to check the options "Copy rich text on copy/cut" and "Use accurate classification" in the Text Editor->Advanced settings dialogue within Visual Studio 2019.

Sample screenshot from settings

like image 179
joakimriedel Avatar answered Sep 07 '25 21:09

joakimriedel