Showing results for 
Search instead for 
Do you mean 

Preserving code snippets in posts

[ Edited ]

If you want to include screen dump text/code in the post, you can utilize the insert code component in the Rich Text editor. 


insert code.jpg



It will include the highlighted code like this:  


. Your code goes here...
UgSession::initialize ( )
// Your Open C++ code here
UgSession::terminate ( )



Source:  Lithium community (password required) 




- - - -
Jerry Sarfati
Siemens PLM Software

Re: Preserving code snippets in posts

[ Edited ]

Actually, you can copy/paste code from Visual Studio

directly into the Rich Text window, because Vis Studio places RTF on the Clipboard when you do a Cut or Copy. Pasting messes up the spaces, but it preserves colors and font, which is nice.


Dim d, x, y As Double

Dim pt As NX.Point

Dim nU = 100 

Dim nV = 70

Dim pts(nU, nV) As Position


Also, as far as I can see, code that you write in the special "Insert Code" window just gets sandwiched between <pre> and </pre> tags, so you could easily just type this HTML yourself, if you wanted.


Re: Preserving code snippets in posts

Maybe I was a little to quick with my kudo Smiley Tongue


I couldn't reproduce the behaviour @Yamada describes.

I tried Visual Studio 2010 Professional, Visual Studio 2015 Express and various methods in Notepad++ (found in Menu -> Plugins -> NppExport) to copy RTF/formatted Text into the forum's editor using Firefox, Internet Explorer and Chrome.


The most I got was the pasted text being wrapped in a <pre>-section automatically. Often the formatted text wouldn't even show up in the editor at all (though pasting to e.g. Word worked fine with preserved formatting).


Is there still a way to get syntax highlighted code in the forum? Or will it boil down to manually editing the HTML?


Would be really cool to have some kind of shortcut to paste formatted/highlighted code! Smiley Happy

Re: Preserving code snippets in posts

I can't get it to work, now, either. But I'm sure that it used to work. As you can see, I managed to get colorized code in my post above, and I certainly didn't type all the RTF gibberish myself. Anyway, I agree that the ability to post colorized code would be very nice.

Re: Preserving code snippets in posts

Sorry, @Yamada, I think I worded my reply a bit wrong. I did not at all mean to imply that your post was wrong. It was just a funny moment, when I read your post, thought "great tip, finally!", kudoed you, and then it didn't work Smiley Very Happy


I suppose, that the feature propably has been removed during some redesign process (as the screenshots in the first post are outdated, too). Hopefully this gets another update, soon Smiley Happy