How can I make VS2010 behave like VS2008 w/r/t indentation? - visual-studio

Situation
I have a plain text file where indentation is important.
line 1
line 1.1 (indented two spaces)
line 1.2 (indented two spaces)
line 1.2.3 (indented four spaces)
In Visual Studio 2008, when I pressed enter, the next line would also be indented four spaces.
However, in Visual Studio 2010, when I press enter, the next line is indented one tab.
Question
Does anybody know where, in the mountain of preferences under Tools > Options, I can return to the way that Visual Studio 2008 worked?
Under Options > Text Editor > Plain Text > Tabs, I see the following:
If I select "None", then I get no indentation when I move to the next line. If I select "Block", then I get TAB indentation (even though the previous line is spaces).
In Visual Studio 2008, my indentation is set to "Block", and I get spaces.
I have no idea what "Smart" indenting is, or why it is disabled.

"Smart" indenting is essentially asking the language service to do indentation, which covers cases like adding an extra indent level after an { in C# files. Since plain text files don't have a language service, it isn't available here. If it was, the behavior (matching indentation from the line above) would be whatever the language decides to do, though I'm pretty certain it respects the "Insert spaces"/"Keeps tabs" option.
"Block" indenting is asking the editor to take care of it, which it takes to mean "maintain the same indent level as the previous line". It appears that, in VS2008, it copied the indentation from the previous line, whereas VS2010 respects the "Insert spaces"/"Keep tabs" setting.
Can you file a bug on Connect about it? I'm not sure if it was changed on purpose or not, so it will help for this to go to our (the editor team's) triage people to make sure.

Related

Visual Studio - disable reversed cursor to select line

I hope this is okay to ask on SO, I'm not sure. I apologize if it shouldn't be here.
I reinstalled Visual Studio Professional 2015 yesterday due to a few issues I was having. With the new installation, my line numbers have a very wide section where the mouse reverses direction and select the entire line if clicked. I don't recall this area being so wide on any of my previous installations of VS2015; I know it was there in the first place. Is there a way to disable this?
This is the area where this happens, boxed in green. It's much wider than the line numbers fill (only 147 lines in this file).
There are two "margins" available in Visual Studio 2015: Selection and Indicator available under Tools > Options > Text Editor > General > Display. Turning these off remove some, but not all of the "extra space" and the feature of highlighting an entire line is still there.
If you want to turn them off because the extra space is bothersome, keep in mind you will not be able to see breakpoints unless "highlight current line" is checked.

Convert virtual spaces into real tabs in visual studio

In Visual studio when I create a newline it sets a caret to the indent that I want. However it's not a real tab indentation until I will type any character at line. So all my empty lines are still fully empty (without '\t') and i want to make VS to convert this virtual indentation into real tabs.
I saw this question is pretty close to what I want but in differense from that I don't write an extension but search an existing solution. Though if there's no other way i will have to do it.

Is there a way to indent lines (not format them) in Visual Studio?

In Eclipse, there are two distinct features: one to format a selection, one to just indent the lines, see e.g. Difference between Ctrl+Shift+F and Ctrl+I in Eclipse. I found the format feature in Visual Studio but how can I actually just indent the lines? Is there some built-in command for that or possibly a 3rd party add-on?
Note: I have asked a couple of friend that use VS daily and they all tried to persuade me that I am looking for the format feature. No I'm not. I tried to live with it for a while and it is just a different feature. I am after the indent/reindent only.
EDIT: I am looking for a clever indent, sometimes called reindent, which is different to just pressing Tab or Shift+Tab (increase/decrease indent level). The indent feature in Eclipse behaves like this:
It places a beginning of current line at the right position, no matter where that line was starting before. So instead of thinking whether you need to increase or descrease the indent level (Tab or Shift+Tab), you just invoke the indent command and it will do the right thing.
Invoking the indent command on an empty line places the caret at the right position for the user to start typing.
It never influences any character beyond the first non-whitespace character.
If you just want to indent some lines, you can
Select them.
Press Tab.
To un-indent them, replace the second step to: Shift+Tab.
You can find more VS shortcuts here.
There are toolbar buttons for this, with wonderfully inconsistent labels (at least in the Visual Studio 2013 I'm using)...
In the "Text Editor" toolbar (in my default setup), I have to buttons whose tooltips are:
"Decrease Line Indent"
"Increase Line Indent"
In the "Customize" dialog, on the "Commands" tab (with "Toolbar" set to "Text Editor") they appear in the list as:
"Line Unindent"
"Line Indent"
And finally, if you press the "Add Command..." button (on the "Customize" dialog) to produce the "Add Command" dialog and select the "Edit" category, you'll see these two entries:
"Outdent"
"Indent"
As far as I can tell, these are all the same two commands, which should do what you want.
They also appear in the Edit -> Advanced menu, at the very bottom.
----- Edit -----
I believe you might be able to turn off all of the "formatting" actions except for indentation, so that when you use the "auto-format" command, only the indentation is "formatted" for you. (Of course this prevents you from ever using the rest of the formatting features without turning them on again, but if you don't use them, this might work!)

How to automatically keep the smart indent in visual studio

I don't quite know how to phrase this question, but basically what happens is:
if i smart indent in visual studio, then click somewhere else on the page or even on the exact same line that has the smart indent, it then goes away, as if I'd had no indenting at all, not even block indenting.
It just puts the cursor/insertion point at the very beginning of the line.
EDIT: BTW I recently formatted my computer and I'm almost certain this wasn't the case before, I'm guessing it's a setting, but I've been fiddling around with all the settings trying to change this, but I can't.
Open Tools->Options. Navigate to Text Editor on the LHS. Select the source type (C++, VB, etc.). Open the tree view node and select Tabs. There, on the RHS you'll find your option

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