Sublime Forum

Copy with Syntax Highlighting?

#1

Is it possible to copy text from sublime with the syntax highlighting being copied as well?

If you copy code from visual studio and paste it in google docs, it retains the colors, both background and text color. Is this possible in Sublime?

0 Likes

#2

Build 4092 introduced a Edit > Copy as HTML command that is set up to do something like this, though at the moment it’s not including the correct mime type to let the receiving application know that the text on the clipboard is HTML, so it pastes as HTML code. This will likely be corrected in an upcoming dev build though.

2 Likes

#3

i used to do that. there’s a plugin for ST3. Don’t remember which one i used, probably “print to html”.

0 Likes

#4

I just started using ST4 and I used the Copy As HTML command in Notepad++ quite a bit for documentation in the Helpsmith app. While the menu command for this in ST4 works fine, there is no shortcut key for it or documented command for my own key binding. This:

    { "keys": ["ctrl+shift+c"], "command": "copy_as_html" }

sort of works but the font isn’t right when I paste it. If there was a menu accelerator for it I could get by with Alt+E+whatever, but the only way to get at it without the mouse is Alt+E, hit the down arrow 5 times and enter… There’s a lot to like about ST4, but unfortunately I may have to stick with Notepad++. It’s easier to configure and all the commands are accessible, functional and documented.

0 Likes

#5

To have the copied HTML include the font settings it has to have enclosing tags. You can enable that using "command": "copy_as_html", "args": { "enclosing_tags": true }.

1 Like