Jacob Stamm
Jacob Stamm

Reputation: 1873

Visual Studio 2015 - C# line break behavior after snippets

Since I've upgraded to Visual Studio 2015, an annoying, even frustrating, behavior has manifested. This occurs whenever I enter some kind of snippet (such as an if block by typing "if" followed by [Tab][Tab], or perhaps highlighting some code and using the "Surround With..." option). When I click after the closing bracket of said snippet and then hit [Enter], I would expect a line break to occur, resulting in something like this:

if (true)
{
    // some code
    // some more code
} // (right here, after the closing bracket, is where I clicked, then hit [Enter])
// new empty line

Instead, the line break does not occur, and the text focus is moved to inside the block after the last line of code, like so:

if (true)
{
    // some code
    // some more code (text focus is now right here)
}

I notice no prompts whatsoever when this behavior occurs, leading me to believe this isn't some "smart" feature that is configurable. Is anyone else experiencing this? If so, what can I do to troubleshoot this?

EDIT:

User42's answer below resolved the issue for me, but here is a video of the issue taking place for those who are experiencing the same thing.

Upvotes: 3

Views: 478

Answers (1)

User42
User42

Reputation: 370

Reproduced with VS2015.

The reason is that you are still in the middle of filling out the argument for the if (see that it is highlighted). Just type the argument and click enter to let VS know you're done. It's a feature, not a bug. :)

Another option would be to edit the snippet. The snippets are stored in:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC#\Snippets\1033\Visual C#

I advise you to first make a copy of a snippet before editing.

Upvotes: 6

Related Questions