I'm using Visual Studio 2005. It always wants to format switch statements like this:
switch (thing)
{
case A:
stuff;
break;
case B:
things;
break;
}
Is there a way to have it indent the cases like this?:
switch (thing)
{
case A:
stuff;
break;
case B:
things;
break;
}
Go here:
Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels
An updated method of doing this, it's not too different.
Tools > Options > Text Editor > (Language) > Code Style > Formatting > Indentation > Indent case labels
Tools | Options | Text Editor | c# -> check 'Ident block contents' checkbox.
Related
Anyone knows how to avoid firefox console to group log entries?
I have seen how to do it with firebug https://superuser.com/questions/645691/does-firebug-not-always-duplicate-repeated-identical-console-logs/646009#646009 but I haven't found any group log entry in about:config section.
I don't want use Firebug, because it's no longer supported or maintained and I really like firefox console.
I try to explain better, I want console to print all logs and not the red badge with number of occurences of one log string:
In the above picture I would like to have two rows of the first log row, two rows of the second and three of the third.
Is this possible?
Thanks in advance
Update [2022-01-24]
Seems like the below option doesn't work as expected. feel free to report it as a bug
Update [2020-01-28]
Firefox team added option to group similar messages, which is enabled by default.
You can access to this option via Console settings
Open up Firefox's dev tools
Select Console tab
Click on gear button (placed at the right of the toolbar)
Change the option as you wish
Original Answer
As I mentioned in comment section, There is no way to achieve this at the moment. maybe you should try to request this feature via Bugzilla#Mozilla
Also you can check Gaps between Firebug and the Firefox DevTools
As a workaround you can append a Math.random() to the log string. That should make all your output messages unique, which would cause them all to be printed. For example:
console.log(yourvariable+" "+Math.random());
There is a settings menu () at the right of the Web Console's toolbar now which contains ✓ Group Similar Messages:
To solve this for any browser, you could use this workaround: Override the console.log command in window to make every subsequent line distinct from the previous line.
This includes toggling between prepending an invisible zero-width whitespace, prepending a timestamp, prepending a linenumber. See below for a few examples:
(function()
{
var prefixconsole = function(key, fnc)
{
var c = window.console[key], i = 0;
window.console[key] = function(str){c.call(window.console, fnc(i++) + str);};
};
// zero padding for linenumber
var pad = function(s, n, c){s=s+'';while(s.length<n){s=c+s;}return s;};
// just choose any of these, or make your own:
var whitespace = function(i){return i%2 ? '\u200B' : ''};
var linenumber = function(i){return pad(i, 6, '0') + ' ';};
var timestamp = function(){return new Date().toISOString() + ' ';};
// apply custom console (maybe also add warn, error, info)
prefixconsole('log', whitespace); // or linenumber, timestamp, etc
})();
Be careful when you copy a log message with a zero-width whitespace.
Although you still cannot do this (as of August of 2018), I have a work-around that may or may not be to your liking.
You have to display something different/unique to a line in the console to avoid the little number and get an individual line.
I am debugging some JavaScript.
I was getting "Return false" with the little blue 3 in the console indicating three false results in a row. (I was not displaying the "true" results.)
I wanted to see all of the three "false" messages in case I was going to do a lot more testing.
I found that, if I inserted another console.log statement that displays something different each time (in my case, I just displayed the input data since it was relatively short), then I would get separate lines for each "Return false" instead of one with the little 3.
So, in the code below, if you uncomment this: "console.log(data);", you will get the data, followed by " Return false" instead of just "false" once with the little 3.
Another option, if you don't want the extra line in the console, is to include both statements in one: "console.log("Return false -- " + data);"
function(data){
...more code here...
// console.log(data);
console.log("Return false ");
return false;
}
threeWords("Hello World hello"); //== True
threeWords("He is 123 man"); //== False
threeWords("1 2 3 4"); //== False
threeWords("bla bla bla bla"); //== True
threeWords("Hi"); // == False
I'm moving my project from Zend Studio 5 to 9.
Zend 9 ruins my indentation. Previously my code was formatted to have a tab be two spaces. Now Zend is using four spaces and some lines are indented further than before.
Before:
$a=1;
$b=1;
$c=1;
for ($i=0; $i<10; $i++)
{
echo "test";
}
Now
$a=1;
$b=1;
$c=1;
for ($i=0; $i<10; $i++)
{
echo "test";
}
I've tried setting the tab policy to "spaces" and the indentation size to "2". But that doesn't work.
I fixed it by setting Displayed tab width to "2".
This is on the page: General > Editors > Text Editors
How can I fold comment blocks inside method blocks to be folded (outlined), just like methods and regions, etc.?
Select the block that you want to hide
Ctrl+M+H
This needs to be done only once. The block will become collapsible afterwards.
Edit + Outlining + Start Automatic Outlining.
I think it might be right...
도구 > 옵션 > 텍스트 편집기 > C/C++ > 서식 > 개요 > 문 블록에 개요 사용 : True --> 모든 블록에 folding/unfolding 사용 가능.
Tool > Option > Text Editor > C/C++ > Form > Outline > Use statement on the block overview : True --> Every block folding / unfolding can be used.
In the case of following string to be parsed.
ford mustang,10,blue~~?bugatti veyron,13,black
I want to replace the ~~? with a carriage return
Replacing with \n just adds the string "\n"
How can this be done?
Make sure Use: Regular expressions is selected in the Find and Replace dialog:
Note that for Visual Studio 2010, this doesn't work in the Visual Studio Productivity Power Tools' Quick Find extension (as of the July 2011 update); instead, you'll need to use the full Find and Replace dialog (use Ctrl+Shift+H, or Edit --> Find and Replace --> Replace in Files), and change the scope to Current Document.
You can also try \x0d\x0a in the "Replace with" box with "Use regular Expression" box checked to get carriage return + line feed using Visual Studio Find/Replace.
Using \n (line feed) is the same as \x0a
If you set Use regular expressions flag then the \n character would be translated. But keep in mind that you would have to modify your search term to be regexp friendly. In your case it should be escaped like this \~\~\?.
If you want to avoid the hassle of escaping the special characters in your search and replacement string when using regular expressions, do the following steps:
Search for your original string, and replace it with "UniqueString42", with regular expressions off.
Search for "UniqueString42" and replace it with "UniqueString42\nUniqueString1337", with regular expressions on
Search for "UniqueString42" and replace it with the first line of your replacement (often your original string), with regular expressions off.
Search for "UniqueString42" and replace it with the second line of your replacement, with regular expressions off.
Note that even if you want to manually pich matches for the first search and replace, you can safely use "replace all" for the three last steps.
Example
For example, if you want to replace this:
public IFoo SomeField { get { return this.SomeField; } }
with that:
public IFoo Foo { get { return this.MyFoo; } }
public IBar Bar { get { return this.MyBar; } }
You would do the following substitutions:
public IFoo SomeField { get { return this.SomeField; } } → XOXOXOXO (regex off).
XOXOXOXO → XOXOXOXO\nHUHUHUHU (regex on).
XOXOXOXO → public IFoo Foo { get { return this.MyFoo; } } (regex off).
HUHUHUHU → public IFoo Bar { get { return this.MyBar; } } (regex off).
You can use Multiline Search and Replace in Visual Studio macro which provides nice GUI for the task.
Just a minor word of warning... a lot of environments use, or need, "\r\n" and not just "\n". I ran into an issue with Visual Studio not matching my regex string at the end of the line because I left off the "\r" of "\r\n", so my string couldn't match with a missing invisible character.
So, if you are doing a find, or a replace, consider the "\r".
For a little more detail on "\r" and "\n", see: https://stackoverflow.com/a/3451192/4427457
Let's say I have a function that takes an object as a parameter and returns a string...
public string Foo(object values) { // return a string }
When working in Visual Studio 2008 (ASP.NET MVC Web Application), I try to pass an object intializer to this function like so:
string x = Foo(new { x = 1, y = 2 });
While I'm typing this out, the intellisense takes over after I type "new " (without quotes) and I end up with "new object " before I can type the opening curly brace.
I imagine the intellisense is trying to help out by assuming I'm going to create something that matches the function declaration, but in this specific case it's annoying. Is there a way I can turn this off for object?
I don't know which of the settings that does this, but I always turn off "Auto list members" and "Parameter information" in the "Text Editor" settings in the options, and it doesn't do that for me.
To get the behaviour that you mention I now have to press Ctrl+Space.