How to prevent Visual Studio 2015 reformatting on uncommenting a block - visual-studio

If I comment out a block of code using the comment comment (Ctrl+E,C) and then uncomment (Ctrl+E,U) then the code is reformatted based on whatever options are set for things like braces in new lines, spacing around brackets, etc.
Is there any way to disable this behaviour and just leave the code as it was?
I don't recall seeing this behaviour prior to Visual Studio 2015.

OK I just found the relevant setting:
Tools -> Options -> Text Editor -> Basic -> Advanced -> Pretty listing (reformatting) of code

Related

Visual Studio code folding not working properly

does someone already has experienced this "issue" on visual studio?
it did not fold the code on the brackets, just on the function header, should have a - on line 32,35 like on the line 25
I had the same problem with python code.
For me this helped:
File -> Preferences -> Settings -> Text Editor -> Folding Strategy -> Set to "indentation"
"Folding Strategy - Controls the strategy for computing folding ranges"
This was set to "auto" for me, after changing to "indentation" it works.
I suspect the "auto" setting uses something smarter which may break depending on system, environment and used imports.
There is a setting in the VS.Code : "Settings / Editor: Folding Strategy" I set this to "indentation" while other option is only "auto".
I guess there sometimes problems with other extensions.
Well that's strange.
You can try a couple things:
Re-opening the IDE.
Try that piece of code somewhere else (to discard a more general issue).
Does it happen anywhere else? If it does, it could be an editor option.
Regards.
Solved:
Visual Studio -> Tools -> Options -> Text Editor -> C\C++- > View and set Outline Statement Blocks to true
I dont know how, but i had this option as false.

Prevent Visual Studio from indenting code after multi-line template

I have recently discovered that Visual Studio likes to indent things after a template which takes up multiple lines, as you can see here:
After the template, in which I like to list parameters on different lines to prevent one huge line, the class declaration is indented by a tab. It indents the whole class declaration, so possibly hundreds of lines end up indented unnecessarily.
This happens every time I use Visual Studio's auto formatting tool, which is rather annoying, as I do want to be able to use auto format (it's very helpful), but just not this specific "feature"(?). I've looked through all the options in Tools -> Options -> Text Editor -> C/C++ -> Formatting, but I have not managed to find one that fixes this issue.
How can I prevent Visual Studio from indenting code after multi-line templates like this?

Visual Studio 2013 auto indent

In Visual Studio 2013, under Tools > Options > Text Editor > File Extension, I have set three file extensions, namely .cginc, .compute, and .shader (these are Unity3D shader files) to use Microsoft Visual C++ for auto formatting.
Sometimes auto indent (for curly braces) works, and sometimes it doesn't...I can't find any rhyme or reason for this. When it doesn't work, it starts every new line flush to the left.
I Google around every couple weeks and can't find an answer.
Does anyone know any setting to make auto indent work consistently?
Try this:
Tools -> Options -> Select the language of your choice (Expand the menu) -> Select Formatting (Expand this sub menu) -> Select Indendation
Once you have selected Indentation, on the right are options displayed - Check/Tick the option: Indent Braces.
Note: You may also format the entire document/file using the shortcut Ctrl+K+D

Visual Studio 2013 - turning off indenting does not work?

Ok - I want indenting turned off in Visual Studio Pro 2013, so...
Tools -> Options -> Text Editor -> All Languages -> Tabs -> Indenting (set to None) -> Click OK
Now, no matter what type of file I edit I get indented text, code, comments; I have indents coming out of my ears !
It's a cruel joke right? Or am I the only person who thought setting Tabs -> Indenting to None meant none?
What magic am I missing? -- and yes, I have found similar posts and NONE (sorry for the pun) of the solutions have worked yet ...
Seriously though -- I know I missed some setting -- but for the life of me I cannot disable this behavior.

javascript visual studio 2013 indentation

I started playing around with javascript on Visual Studio 2013 and I couldn't figure out why it is not automatically positioning the cursor to the correct indentation level, instead always resetting back to the head. For example:
function foo(y) {
var f = function bar(x) {
|<-- cursor should be here, but ends up
|<-- over here
}
Does anyone else see this and how do you change it?
I have the typescript, nodejs plugin installed and that's about it.
With a bit of research, things started working for me. First check that, Tools -> Options -> Text Editor -> Javascript -> Tabs -> Indenting is set to 'Smart'. Next restart VS. For me restarting was important since, apparently, my file had some mixed line-endings and that was throwing off the indentation engine. Hope this helps someone.
In my case, the whole javascript formatting stopped working for every file, I could play with language options and restart VS, nothing helped, until I unchecked:
Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Language Service -> Enable the new JavaScript language service
The editor returned to old school javascript formatting, which is sufficient for me.
I'm not sure if this applies to Visual Studio 2013 (the original question), but in 2015 at least, you can select the text in your JavaScript file you want to format, right-click, and then choose "Format Selection". There's a keyboard short-cut as well (Ctrl-K, Ctrl-F).
If you already have Tools -> Options -> Text Editor -> Javascript -> Tabs -> Indenting set to 'Smart', then try setting this option (the Indenting setting) to 'None' and click OK.
Open the Options back up and, set Tools -> Options -> Text Editor -> Javascript -> Tabs -> Indenting back to 'Smart', click OK.
Close and reopen the file you were working on.

Resources