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.
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.
Ran into this question as I was trying to copy and paste with syntax highlighting from Visual Studio (not Code). As far as I see, it is not possible OOTB.
I am using Visual Studio Enterprise 2019 (v16.7.4), trying to copy C# code (tried CSHTML also).
BUT, I found this article, which seemed to indicate that Visual Studio Code OOTB would Ctrl+C Ctrl+V right into an Outlook email or Word document without a plugin or fancy keyboard shortcut, and I was successful!
I am using Visual Studio Code v1.49.2, and copying C# code. Copying CSHTML also worked.
I took the suggestion above, went to the command pallet, clicked on the clog to the right, and used ctl + c for the key bindings. Now, when I copy from VSCode to OneNote, I get the source formatting. It works!
Related
I think it should be quite straightforward, however, I cannot seem to find this option in visual studio code.
Could you tell me if it is possible and how to enable line numbers in visual studio code when coding in a python notebook?
FYI: it is possible to use visual studio code with a python notebook (you can check more info here)
You have to press L after clicking on the left side of the code block.
as mention in the link provided you just need to press the L key
https://code.visualstudio.com/docs/python/jupyter-support#_enabledisable-line-numbers
The "Go to Symbol in File..." command in Visual Studio Code is really slow for C++ files. I'm coming from Sublime Text 3, which is super fast in this regard, but Sublime Text 3 also indexes the project, so I'm guessing that's the key. Does anyone know of a plugin that will do the same for Visual Studio Code?
It turns out, the C/C++ extension is responsible for this, and there is a bug where the extension is searching the entire database rather than the just the file.
https://github.com/Microsoft/vscode-cpptools/issues/1472
I am using Visual Studio Code and want to copy code from it, but I want to preserve the syntax highlighting.
I want something like "Copy as HTML" , "Copy as HTML with syntax and background intact" or the like. What extensions or plugins do I need to use to get this functionality?
This is not currently possible, you can +1 the issue to help prioritize it https://github.com/Microsoft/vscode/issues/3518
I saw This question about the "Auto ID on Paste" tool being unavailable on newer versions of Visual Studio, and I know about the workaround that is being currently used (comment a line, paste, undo comment)
But I'm not comfortable with those workarounds, I think it would be easier if I could just install one plugin that allows me to paste elements without generating IDs automatically.
Is there any plugin that does this?
To automate the workaround, you can create the following command in Visual Commander and assign a keyboard shortcut to it:
DTE.ExecuteCommand("Edit.CommentSelection")
DTE.ExecuteCommand("Edit.Paste")
DTE.ExecuteCommand("Edit.UncommentSelection")
I do not want Vscode to open up another window while debugging. Is there a way to attach this window inside the IDE?
If the above is impossible, is there a way to choose a more usable terminal? The default terminal doesn't allow for text selection which makes it unacceptable.
Since VSCode is not an IDE, we do not have a built-in terminal.
I tried the terminals on OS X, Linux, and Windows. They all allow me to select and copy text (however on Windows it is through the 'Edit' > 'Mark' mechanism).
Andre Weinand, Visual Studio Code
The vscode forums have a request for an integrated terminal with a number of upvotes, i'd advise adding your voice to the chorus.
It's a must to output the debug console writes to an attached panel in Visual Studio Code. Click an highlight a word in the debug output console text to do a global project search to find all code containing that string. A common thing like tagging error blocks with a unique ID that gets output to the console when the error happens. Full text search of the project source code tree for the ID...