How to stop Visual Studio 2019 from formatting my comments? - visual-studio

Okay, so, hopefully an easy question here...
Visual Studio, using C++ ... and this is just an annoyance, but I've been putting up with it for three months now, it interrupts my workflow, and I just want it gone...
If I type the beginning of a block comment:
/*
...and press return, Visual studio "helpfully" starts adding asterisks on each line, like so:
/*
*
*
*
And there doesn't appear to correlate with ANY of the options in the C++ text editor settings. Can someone clue me in on how to make it JUST STOP. Thank you.

Okay, there IS an answer, and I was able to find it by using different keywords:
How to disable the automatic asterisk in Visual Studio when adding a multi-line comment in C#?
This answer is no longer correct, but the PROCESS is. For posterity: Export the settings, look for "continuecommentsonenter" and change it to false. Then import the settings again.

Related

Visual Studio -> wrap every parameter

Using Visual Studio 2019, I found a really useful refactoring option in 'Quick actions and refactoring':
(might come from PowerTools, whatever)
I just wondered how:
I can make this wrapping settings a default formatting settings
Or apply this formatting on my whole solution at once (without resharper)
For the later, a solution with Visual Studio Code would be perfect as well !
Thanks for your help
You can try using Rewrap extension which formats code, comments, and other text to a given line length (80 by default).
The main Rewrap command is: Rewrap Code / Comment, by default bound to
Alt+Q. Put the text cursor inside a comment line, block or plain text
paragraph and invoke the command to wrap. You can also select just a few lines, or multiple comments in one selection.
There is currently an Open request for this in the VS Code Issue tracker on GitHub

Can we change all the word at once in visual studio

If I made the same mistake several times in the same code. Is it possible for me to change all the mistakes at once rather than finding each mistake and correcting it.
For Ex:- If I have written prnt instead of print several times at different places can I change it at once and apply it for all others rather than going at each place and correcting it manually.
You can use the Find and Replace feature in Visual Studio to find prnt and replace it with print. Use Ctrl+Shift+H as a quick shortcut to find and replace.
visual studio support multiple edit.
You can use Shift+ALT+; to edit all the same words in current file.
For this blog: Visual Studio Tips and tricks: Multi-line and multi-cursor editing you can get more infomation.
You can also change it in for the whole solution.
Use Ctrl+Shift+H on visual studio set the word you want to replace, type in the new word to be replaced, set whether it should be replaced for the entire solution or for that document alone. click replace.
Cool right?

How to automatically add // on new line of comment in visual studio 2012

In Visual Studio, I am trying to automatically add the comment marker // when I enter a new line in a comment similar to how visual studio adds a preceding * in a block comment. For bonus points, I would also like it to keep the indentation of the previous line, which it also does for block comments. Looking through the options and available extensions, I was not able to find a settings to do this, although it seems like it would be fairly straight forward since it would just have to look for // instead of /*.
I work in both C# and C++ so it would be preferable if this would work for both, and on my setup it doesn't appear that VS adds the asterisk in C++.

Visual Studio 2010 - Curly Braces auto-align has changed, how do I fix this?

Update: Since I see this is one of my most looked at questions, now a few years later I should point out what I found to be the most common cause of this problem: bad syntax elsewhere in your code. 100% of the time I've had this happen, it was because I'd forgotten a curly brace for another block of code, or I had a dangling if, or an earlier line of code I didn't finish. Check for IDE errors first for something like ") or } expected"
Original Question:
I feel like this is an all time dumb question to ask, but I have no idea how to fix this and google is turning up nothing.
In visual studio, when I type:
try {
}
VS would automatically reformat it to
try
{
}
But now it's just leaving it at the first one. I assume I accidentally hit a hotkey or something. Help me fix this please?
Tools->Options
Click Text Editor -> Whatever language -> Formatting
Tools->Options->Text Editor->C# (or whatever language)->Formatting->New Lines
Select the options you want.
If you have Power Commands installed you can then go to the Tools->Options->Power Commands and make sure "Format Document on Save" is selected.
Whenever you save the edited file the Curly Braces will be auto aligned.
In addition to the default Visual Studio settings mentioned, for ReSharper users, this is configured via:
ReSharper [menu] -> Options
In the Options dialog, navigate to Environment -> Editor -> Editor Behavior -> "Auto-format on closing brace". See image:
9 times out of 10 this problem is caused by bad code elsewhere on my document. Either I'm missing a ; on a line, or perhaps a closing }. Visual Studio is unable to figure out what I'm trying to write in code and thus it's unable to format. Check for compiler errors, fix them, and then press Ctrl+K then Ctrl + D to make Visual Studio reformat the current document (your hotkeys may vary, depending on the version of Visual Studio and your settings).

How do I stop Visual Studio from automatically inserting asterisk during a block comment?

I'm tearing my hair out with this one. If I start a block comment /* in VS.NET 2005+ then carriage return, Visual Studio insists that I have another asterisk *. I know there's an option to turn this off but I just can't find it. Anyone know how to turn this feature off?
Update: this setting was changed in VS 2015 update 2. See this answer.
This post addresses your question. The gist of it is:
Text Editor > C# > Advanced > Generate XML documentation comments for ///
Visual Studio 2015 Update 2 has (finally) addressed this problem!
A new option as been added to Tools > Options > Text Editor > C# > Advanced named Insert * at the start of new lines when writing /* */ comments.
Disabling this option prevents the editor from automatically prefixing block comments with asterisks. It only took 7.5 years and 4 major releases :)
Try this:
#if false
whatever you want here
and here
#endif

Resources