Is there a shortcut to jump outside of a code block, right after a closing brace }
of a current code block?
Let me explain.
Let's say there's a method:
private void Button_Click(object sender, EventArgs e)
{
if (enableCheckbox.Checked == true)
{
if (labelToChange.Text == "Right")
{
labelToChange.Text = "Left";
}
else
{
labelToChange.Text = "Right";
}
}
}
And my cursor is somewhere on the line labelToChange.Text = "Left";
.
I would like to make it to jump to the closing brace }
of current if (labelToChange.Text == "Right")
code block by pressing Ctrl+]
.
Then if I press Ctrl+]
again, I would like it to jump to closing brace }
of if (enableCheckbox.Checked == true)
code block.
And then if Press Ctrl+]
for the third time in a row, I would like to jump to the closing brace }
of a code block of a method private void Button_Click(object sender, EventArgs e)
.
Here's what I'm trying to achieve in motion:
I was managed to achieve this behavior in WebStorm and PhpStorm by using a macro:
It goes to the end of code block and then it goes to the end of the line, so it stops outside of closing brace.
Comes very handy all the time when I am working with multiple code blocks: if/else, writing methods, anything, I use it all the time in WebStorm and PhpStorm.
Is there a way to achieve this in Visual Studio?
I know about default Ctrl+]
shortcut, the problem with Edit.GoToBrace
command is that it goes to the closing brace }
only when cursor is at the opening brace {
but not when cursor is anywhere else inside the code block.
PS Yes, I did check similar threads:
- Go to closing Tag in Visual studio (using Resharper)?
- Jump to closing bracket in Visual Studio Code
- Go to Matching Brace in Visual Studio?
- move out of closing brace in visual studio shortcut
None of them help me to find a solution to my problem. Please help.