What I want is so simple. In Visual Studio Code, I want to copy the value of a text variable from the Watch window into memory.
I understand that, in the watch window, the text is escaped to put everything on one line. In other words,
Hello
world
is displayed as Hello\nworld in the Watch window. That makes sense.
But when I right-click on a string variable in the Watch window and select "Copy Value", I expect the copied value to be
Hello
world
not
'Hello\nworld'
Is there a way to do this in VSC (without the tedious need to search and replace for escape characters)?
(If you're as stumped as me, Upvote in solidarity.)
Old question but here goes:
This may depend on which debugger you are using, the below works in node/JavaScript.
Go to the Debug Console tab, and type the var name or expression at the prompt.
The debugger outputs the value, and you can select and copy it from there.
Related
So, I have some code for a Rect variable mageSection:
And I'd like to copy the same code for a different variable warriorSection. To achieve this:
So I'd like to know if there is a visual studio shortcut for allow you to change variable name in multiple line in visual studio without refactoring the whole variable name.i.e. I don't have to manually change those names from mageSection to warriorSectionfor these 4 lines.
It is a question about shortcut in visual studio rather than writing functions, as I'd like to know the shortcut for this. Many thanks!
Copy and paste the section of code.
Now select the pasted code and hit Ctrl-H to bring up the Quick Replace dialog.
In the top box, type "mageSection".
In the bottom box, type "warriorSection".
Hit Enter and it will find the first occurrence and replace it.
Hit Enter three more times...done.
If I'm understanding your question correctly you should be able to hold down alt while clicking into multiple lines and change them all at once. Then hit ESC to exit multiline editing.
When I am stepping through code in c# (not sure if it's an issue in VB.NET) and looking at SQL stored in a string variable, sometimes I like to copy it and paste it into Notepad or my SQL program. If it contains carriage returns, though, it actually copies to my clipboard as line1\r\nline2. Is there a native method of copying this with actual carriage returns rather than carriage return escape codes?
Edit: This also applies to tabs which show as \t. This is happening because my code is reading SQL from a text file and the text file contains carriage returns and tabs. The alternative is to 1) not have any carriage returns or tabs in the SQL (which makes for ugly SQL) or 2) strip them out when reading the SQL into my string variable. I am not really keen to those options just for the sake of simplifying the debugging process, though.
It depends where you copy the value from.
If you hover your mouse over the variable when debugging, or look in the Locals window, you should see a little magnifying glass symbol in the tooltip.
Clicking this will open the Text Visualiser which should take account of any linebreaks.
For example, if my code is:
string test = "hello" + Environment.NewLine + "world";
Then I can look in Locals (notice it still shows \r\n there) or hover over test to see:
This opens the Text Visualiser from where you can copy/paste:
Put a breakpoint on the statment which has the variable (whole value you want to copy). As the control comes on the statement, move your mouse-pointer on the variable name. You will see a balloon box showing the variable name, a binocular icon and the value of the variable. Click on the binocular icon or the small down-arrow icon beside the binocular icon to view in it in text visualizer. Hope this is what you are looking at. This is in context with C# and hopefully its the same in VB.NET (but not sure).
In vs2008 when using the debugger and copying a string's current value, automatically change
\\
to
\
I end up having to debug long paths and always get things like
"e:\\eeeee\\blah\\d\\ddd\\fff\\bbbb\\rrrrr\\rrss\\sssss\\somefile.exe"
I then I have to go manually replace every doubleslash. Is there a quick dumb way so the variable gets put on the clipboard the way it would look on the screen?
Look at the far right of the box, there's a spy glass icon there. Click it.
That's the Text Visualizer. It displays the string the way it would appear if you wrote it to, say, the console. With the escapes applied and \r\n actually breaking the string into the next line. Copy and paste from that.
Did you try working with C# verbatim strings ? i.e. - #"string with \ backslash"?
ok, possibly insanely n00b question or something i have overlooked in Xcode prefs: On pressing return, in stead of Xcode's syntax-aware indentation doing smart indent from whatever brackets i've used on the previous line, how can I make it so Xcode indents just from the beginning of the previous line?
From the picture below, first block of code is what i got, second block of code is what I want.
Visual representation:
visual representation http://img704.imageshack.us/img704/289/screenshot20100504at122.png
As an alternative to xcodes formatting, you can use Uncrustify. It can understand Objective as well as a variety of other languages. I set mine up as a script in xcode and assigned it a hot key so that it reformats the whole file or just the selected code.
Ok, this one has been driving me bonkers for ages and VS 2010 hasn't improved this. Say I have a variable like so
string szSql =
#"SELECT
Foo, Bar
FROM
Table
WHERE
Foo = Bar";
If I'm inspecting this in the debugger and choose "Copy Value" the value put into the clipboard has \r\n's in place of the carriage returns which is a bit of a pain. Is there a way to change this behaviour? (I know I can print it in the command window...)
Cheers,
Alex
Append ,nq (short for no quotes) to the variable name in the watch window and it will display the string without escape characters, which you could then copy. For reference the MSDN document is here.
Use the "text visualizer" popup on the value and copy it to the clipboard from there. It will be unescaped.
For lengthy text, such as a large xml document, I always use the immediate window. Just type this in and hit enter:
System.Diagnostics.Debug.WriteLine(szSql)
and it will spit out the text with line breaks and without escape characters. I then copy from the immediate window.