The Interactive Window in Visual Studio is a great utility to play around the code, language features, API’s and other .NET framework features. The Interactive Window also support features like IntelliSense, syntax highlighting and navigating through executed commands. Previously we have seen several tips around the C# Interactive Window, but there is one very interesting feature you may overlooked, in fact, I missed that as well. The Interactive Window, allows you to copy the source code only (Copy Code) so that you can directly paste them back into your main code editor.
Previous Tips related with Interactive Window
- Command Line C# Interactive Script Execution for Visual Studio
- “Initialize Interactive with Project”– Run Interactive with context to Project–Visual Studio
- Use C# Interactive Window for your coding experiment in Visual Studio
- Executing C# Scripts from Command Line or C# Interactive Windows in Visual Studio
- Executing C# Scripts from Command Line or C# Interactive Windows in Visual Studio
- “Execute in Interactive”– Send to C# Interactive Window – Visual Studio
Now consider, inside Interactive Window, you have a set of code snippet along with the output, or other messages. Of course, you want only the Code part to take back in the main editor. At this time, you may select the code block individually, one by one and use regular Copy Option, Or, select all the content and then use “Copy Code” (Ctrl+Shift+C) which will copy only the code related lines in the clipboard.
Related Tip : Did you know – In Visual Studio you can copy multiple code blocks together and paste them one by one ?
If you go back into the main editor, and paste it. You will find only the code lines are in placed.
Hope this helps
Pingback: Dew Drop - July 25, 2017 (#2527) - Morning Dew
Pingback: Compelling Sunday – 25 Posts on Programming and QA