visual studio indentation has been changed automatically? - visual-studio

I have a file from third party where the curly brackets were in the next line but today when i see, all the brackets are moved on the same line as function name.
i would like to revert back all at once, please help.
Thanks in advance,
Sagar

In the Top Menu
Tools -> Options -> Text Editor -> C# -> Formatting -> New Lines
there you find New line options for braces
I guess thats what you´re looking for

Related

Unexpected opening curly bracket indentation

If I type if (true) Enter
the cursor will be indented like
and if I continue with { Enter }, I will get a brace layout like
Why?
I expect the braces to be like
In resharpers Braces layout section I have setup braces layout to be At next line (BSD style).
In visual studios options, going into Text Editor, C#, Code Style, Formatting, Indentation I have the checkbox Indent open and close braces checkbox unchecked.
How is it possible with two separate options sections for code style, both Visual Studio and Resharper? Who wins?
I think the solution is to:
go to Visual Studio Options -> Text Editor -> All Languages -> Tabs and set Indenting to Block, then
go to ReSharper Options -> Environment -> Editor -> Editor Behavior and make sure Smart Indent on Enter is unchecked.

Visual Studio 2015 - arbitrary cursor position on empty line

Initial note: I'm not getting any responses over on superuser to my question, so please allow me to ask this here:
I inherited a VS solution with a bunch of unorthodox settings. I'm not at liberty to wipe out all those settings and start over. So there is 1 setting I want to change back to VS default but cannot find it.
In a normal/default VS c# environment, when you click the mouse on a line of code that hasn't been written yet (empty, no spaces, no code, no tabs), the cursor automatically positions to the beginning of where the line of code should begin. If it's just inside a foreach, if, or etc, it will indent a bit from the left edge according to tab rules, etc.
But in the weird VS settings I have, wherever I click, the cursor positions at that exact spot. So if I click on col 20 of the next line, the cursor remains at col 20 rather than auto-repositioning to col 5 or wherever it should be. This is SO annoying because I can't always eyeball where the cursor should be and I end up clicking at the end of the previous line, then hitting ENTER, at which time it goes to the next line and positions the cursor at the right place.
How can I fix this?
It is controlled by the Enable virtual space option. See Visual Studio options - Text Editor - C#. By default it is off/unchecked.
I resolved this issue by applying Sergey's suggested change (Visual Studio options -> Text Editor -> C# -> Enable Virtual Space [check]), but also enabled (Options -> Text Editor -> C# -> Tabs -> Smart).

Visual Studio 2013 Ultimate: Caret goes to wherever the mouse clicked

my VS2013 is configured at C# layout. Whenever I click an empty space in a file, say somewhere far right to a line of code that has ended well before, the caret moves where I click and spaces are inserted between the last character of the current line and the caret, regardless the fact that the indent settings are at "Keep tabs".
This is annoying to me. Could anyone tell me how to fix this? When I click an empty space after a line, I expect the caret goes to the right of the last character of the line.
Sounds like Virtual Space. Turn it off using Tools -> Options -> Text Editor -> All Languages (or your chosen language) and uncheck Enable Virtual Space.

Code template's indentation is buggy for code behind files in VS2005?

Not sure if anyone else has come across this yet. I like to use a an indent of 2 or 3 and not the default 4 for visual studio because i find my code runs a bit far to the right and I prefer to not code over column 80 for readability's sake. When I change the indent and tabs to 2 using tools >> options >> Text Editor >> C# >> tabs and also set it to "keep tabs" then new classes created are fine. BUT if I create a new ASPX page with a code behind page, the code behind page's initial code keeps a 4 space indent although i specified 2. I have to format the document (a quick ctrl e, d) but it is still irritating. Anyone else come across this?
Try setting Tools -> Options -> Text Editor -> All Languages -> Tabs instead of C# -> Tabs.
Alternatively try a different font or try breaking your code up into smaller pieces by extracting methods via the Visual Studio built-in refactoring tools, etc.
Just had a look now. All languages are already set. I could break up my code further but don't want it to get into spaghetti code. I like my methods do a logical unit of work :)

Can you set Visual Studio's "smart indent" to not remove tabs in blank lines?

When Visual Studio (2005) has Options -> Text Editor -> C/C++ -> Tabs -> Indenting set to Smart it will automatically indent code blocks and line up squiggly brackets, {}, as expected. However, if you hit enter inside a code block, move the cursor to another line, and then move it back, the inserted tabs are gone and the cursor is positioned all the way to the left. Is there a way to set Visual Studio to keep these tabs?
As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.
Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that you've described).
This is an annoyance to myself as well. Anytime the code is reformatted the blank lines are de-tabbed.
You might look at this: http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7 it's not exactly a solution but a step in the right direction

Resources