So if I have something like this:
if (a>b)
return true;
and I decide later that I want to change it to this:
if (a>b)
{
a++;
return true;
}
Is there a quicker way to have the existing code under the if statement go directly into the newly made curly braces? Because currently if I were to add the curly braces after creating the if statement in the first example I'd have to cut the "return true" from under the new braces and paste it between the newly made curly braces. This is what it looks like:
if (a>b)
{
}
return true;
and it's pretty annoying. Is there a fix to this or do we have to manually copy and paste the existing line in between the brackets?
P.S. I'm using Microsoft Visual Studio 2015 ver 3 and programming in c# but I think this problem occurs in other languages too like c++.
Go to matching brace in Visual Studio with Ctrl+} shortcut To move the caret to the matching brace of the one it's currently on press Ctrl+}. This is very handy for navigating code which might have multiple levels of if/else block nesting, although do try and avoid this kind of code by using guard clauses if you can.
CompleteWord in Microsoft Visual Studio, Alt+Right navigates forward.
You can use the navigation bar (the drop-down boxes at the top of the code window) to navigate to code in a codebase. You can choose a type or member to go directly to it. The navigation bar appears when you edit code in a Visual Basic, C#, or C++ code base.
Highlight the code and then press Alt + Up Arrow. Move code down with Alt + Down Arrow. Works with multiple lines too. Plus, you don't have to highlight the entire line. As long as one character is highlighted, it works.
https://blogs.msdn.microsoft.com/zainnab/2013/07/01/visual-studio-2013-preview-moving-lines-of-code/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With