Visual Studio: Tab key selects and highlights code [duplicate] - visual-studio-2013

This question already has answers here:
Hitting Tab in Visual Studio selects block instead of adding indentation
(3 answers)
Closed 6 years ago.
If I place my cursor inside a multi-line comment:
/*
* place cursor after the asterisk and before the word 'place'
*/
if (x == 0)
{
// some code
}
... and hit tab, Visual Studio doesn't add whitespace as usual. Instead, it highlights the entire comment (all three lines, in the example). If I hit tab again, it will select and highlight the next statement or block of statements. In my example, it highlights the entire if.
How do I fix this and make Visual Studio tab things over? I want tab to behave like a tab.
I'm using Visual Studio 2013 Ultimate with Resharper 9. It started doing this yesterday, and I have no idea why.

Figured it out. It wasn't in VS' settings! Somehow Resharper's configuration was changed. In Resharper's settings:
Environment > Editor > Editor Behavior
Uncheck the box labeled "Structural Navigation". Click "Save".

Related

Can't print } on Visual Studio 2017 on Italian keyboard [duplicate]

This question already has an answer here:
Recent Visual Studio update introduced shortcut used to create closing curly brace on my keyboard: how to find offending command?
(1 answer)
Closed 4 years ago.
When I press the keyboard shortcut CTRL+ALT+SHIFT+] on an Italian keyboard to add a closed curly brace, Visual Studio selects a block of my code instead of printing it.
I have already tried to reset the keyboard mapping on Visual Studio but to no avail.
Other programs works without problems. How can I fix this problem?
It is a new feature appeared in Visual Studio 2017 version 15.8.0.
It is called ExpandSelectionToContainingBlock and it is mapped to the keyboard shortcut CTRL+ALT+SHIFT+] or CTRL+ALT+SHIFT++ (For VS in Italian)
But this mapping has removed the ability, from some keyboards without the key for the closing brace (like the Italian one), to press those keys and get the, indispensable for many programming languages, close curly brace.
As far as I know there are two workarounds
Go to Tools menu and select Customize
Press the Keyboard button
Search for Edit.ExpandSelectionToContainingBlock
Press Remove
or just use the numeric keypad and press
ALT+0125
For Italian readers with the Italian version of VS, the search above at point 3 should be for Modifica.Espandiselezioneabloccocontenitore. I don't know if other languages are affected by this 'translation vice' but it is a thing to be aware of.
The problem has already been reported to MS (Thanks Albireo)
EDIT: It seems that they have fixed the problem, in version 18.5.2 there is anything assigned to the shortcut. But I am not sure if this is an effect of my previous action or if this (no shortcut) is the real default now.

What does the underline that is automatically put under the end brace by IntelliSense brace completion denote? [duplicate]

Visual Studio 2013 frequently marks my code with a green _ ( green underscore bar).
What does it represent and is there a feature that it's linked to, like auto complete or intellisense ?
This is the automatic brace completion feature that was introduced in Visual Studio 2013 (although, like so many new features in Visual Studio, it was actually in the Productivity Power Tools extension first).
When you write an opening brace, Visual Studio 2013 inserts a closing brace for you automatically. The underline simply indicates that the code editor is still in brace-complete mode. While in this mode, Visual Studio is waiting to see if you close the brace yourself, in which case it will remove the redundant brace and move the text cursor if necessary. While in this mode, you can also press tab to move the cursor past the closing brace; although, this only seems to work when both braces are on the same line and there is nothing (except whitespace) between the cursor and the closing brace. Moving the cursor outside of the braces exits this mode.
This feature works not only for braces, but also parentheses, square brackets, and quotes (single and double).
You can enable or disable this feature by checking or unchecking the Automatic brace completion checkbox located in:
Tools → Options → Text Editor → All Languages* → General
* or a specific language, e.g. C#
Just go to tools, then options.
You will see the item fonts & Colors there you can choose what you wanna do in such part of your code, such as choosing the type of text and color.

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).

VS 2010: How do I get "next tab", "prev tab" keyboard shortcut working? [duplicate]

This question already has answers here:
Changing Ctrl + Tab behavior for moving between documents in Visual Studio
(14 answers)
Closed 9 years ago.
How do I get "next tab", "prev tab" keyboard shortcuts to work in Visual Studios 2010?
(For a more precise description of the functionality I need please see the firefox/chrome/etc and how they do their "ctrl-pgdn" and "ctrl-pgup" keyboard shortcuts).
This should be extrememly easy... and yet I can't seem to figure it out.
NOTE:
I do know that there is a "ctrl-tab" that is similar... but it only scrolls through the "most recently used list" which is different. I don't care about "the most recently used list". I just want to go to the right/left tab.
You should map the Window.NextDocumentWellTab and not View.NextTab and remove it from any other functions its assigned to. Only mapping it will not work, you also need to unmap from anything else its being used on, apparently.
This is what my keyboard configuration looks like:
Looked into this some more, and it turns you need to install the Productivity Tools. That gives you that NextDocumentWellTab function.
Under Visual Studio 2010 Professional, this keyboard shortcut goes by the name Window.PreviousDocumentWindow and Window.NextDocumentWindow.
Important Note: By default, Ctrl-PgUp and Ctrl-PgDown are assigned to Edit.ViewTop and Edit.ViewBottom respectively, so make sure to remove the existing keyboard assignment before trying out your new assignment. If you don't, the keyboard commands you enter will continue to be interpreted as the most "specific" shortcut (Edit.ViewTop or Edit.ViewBottom) since you're most likely trying this out in the Edit view!

Is it possible to copy code from Visual Studio (VB.NET) without indentation?

As I am copying something from within a method, and pasting it into a word document, the code I am copying is already indented. When I paste it I therefore end up with a load of white space next to each line.
I need to copy without this. In C# I can just unindent my code, hit copy, and then indent it back again using the buttons in the IDE. But Visual Basic automatically forces indentation so any attempts to change it don't work.
Visual Studio supports block selection. Press the alt key and drag the cursor to start block selection.
Visual Studio Select Block Text
This is a very useful feature, specially when pasting code here on SO. Visual Studio 2010 will even support multi-line editing using the box selection.
Unfortunately, it seems VB doesn't support the Edit.Advanced.Tabify/Untabify or Increase / Decrease Indent commands.
Here is what you can do:
Go to Tools -> Options -> Text Editor and uncheck "pretty listing (reformatting) of code"
Select the text block you wish to copy without indentation
Go to Edit -> Advanced and click "Delete Horizontal White Space" (or: Ctrl K, Ctrl )
Copy and paste your code in Word.
Turn the "pretty listing" option back on.
the "Delete Horizontal White Space" command will unindent the entire selected text so that there is no tab/whitespace to the left of any line (unlike Block Selection, as prorposed by João Angelo, which will unindent the selected block but keep any indentation within the block).
You may use the Visual Studio extension Copy for review. Besides some formatting, it removes unnecessary whitespace. It works for Visual Basic, among other languages.
Disclosure: I am the author of that extension. Please notify me, if I can improve it to your needs.

Resources