In Visual Studio Code, is it possible to copy selected code to the clipboard with the syntax highlighting? I want to be able to paste into a Word doc or e-mail.
Regular Visual Studio does this by default (it puts both text and RTF formats on the clipboard).
I see that I can "Toggle Developer Tools" and locate the div (with class="view-lines") that has the code, so maybe there is a way to use that chunk of html, but I don't see an easy way to just copy the formatted code and paste into Word or an e-mail.
Go to Tools -> Options. type copy in the search box. Under Text Editor -> Advanced ... Check Copy rich text on copy/cut.
“copy paste above line in vs code” Code AnswerOn Windows: Shift + Alt + Up/Down. On Mac: Shift + Option + Up/Down. On Ubuntu: Ctrl + Shift + Alt + Up/Down.
Select the portion of code you'd like to copy, then go the Edit menu and select Copy Special -> Copy as RTF. Your code, complete with syntax highlighting colors, is now stored on the clipboard. Simply press Ctrl + V in your other application to paste the code with syntax highlighting. It's that simple!
Open code file or select code snippet in Text Editor, then press F1 and then select/type Copy Syntax , or right click the Text Editor and then click Copy Syntax in context menu, the code with syntax highlight will copy to clipboard.
According to the 1.10 changelog : https://code.visualstudio.com/updates/v1_10#_copy-with-syntax-highlighting
It is now possible with that command : editor.action.clipboardCopyWithSyntaxHighlightingAction
Type/paste it in command box (ctrl+shift+p
or F1
)
Use the command "Copy With Syntax Highlighting".
- Highlight the code
Ctrl + Shift + p
to open the Command Palette- Type / Select
Copy With Syntax Highlighting
It is available since VS Code v1.43 (Feb 2020), as @robert4 mentioned in comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With