Say you have a large amount of C# code in an if statement. If you place your carat next to the opening bracket, is there a hotkey or something in ReSharper that will automatically take you to the closing bracket?
VS offers this shortcut, regardless of whether you have R# installed.
Ctrl + ] will take you to the opening brace. Subsequent presses will jump between the RHS/LHS of the scope.
See Go to Matching Brace in Visual Studio? (now as an answer as requested!)
ReSharper assigns the shortcut (Control + ´ - I have german keyboard) to a different command. In order to restore it go to Tools - Options - Environment - Keyboard, search for Edit.GotoBrace and enter the desired shortcut key.
See to what command it is currently assigned and then remove it for this command first by searching this command and clicking Remove. Then again search for Edit.GotoBrace and assign the shortcut.
Directly assigning without Removing it first didn´t work.
Visual Studio's shortcut is (under the IntelliJ shortcut set): Control + ] when your cursor is on the opening brace goes to the ending brace. The inverse is also true.
Related
In Xcode, if the cursor is on one brace (or bracket or parenthesis) of a matched pair, what keyboard shortcut will jump to the matching brace? Or how can I create such a shortcut?
An example of the feature I'm after is the "goto brace" shortcut in Visual Studio.
There is a Balance Delimiters menu command. So simply assign it any keyboard shortcut you prefer (all commands have customizable key bindings). You can also double-click the first delimiter to perform the same action.
A partial solution is to use code folding. For example, to jump from the opening brace to the closing brace:
Put the cursor just after the opening brace.
Fold with ⌥⌘←.
Arrow the cursor right to just before the closing brace.
Unfold with ⌥⌘←.
Since Xcode now has Vim mode you can use that and just hit %.
(Adding this answer for completeness - I understand it kind of amounts to "just use Vim".)
Visual Studio autocompletes brackets and tags and then shifts the cursor inside a bracket/tag upon creation.
I usually have to hit END then ENTER to continue past the tag, it would be really useful to 'jump' over the closing tag/bracket and possibly to the next line.
Is there a fundamental keyboard shortcut I'm missing here in order to accomplish this?
Can't find this in the MSDN VS Keyboard Shortcut manual either.
The keyboard shortcut you are looking for is Ctrl + Shift + Enter.
Pressing this will take you to the next line instead of inserting an enter, allowing you to move the cursor outside of the tag.
I just started using Visual Studio 2013. I liked the auto brace completion feature. But in C#, when I press enter after entering {, no extra line to write our code is formed, like in eclipse. Instead the cursor will be at the left side of the }. Did anybody notice that? Is there a way to fix it.
When I press Enter key after putting brace, the editor is like this:
class Example {
|}
(The cursor is where the pipeline character is..)
EDIT:
I just found that in Visual C++ 2013, the braces work as expected.
class Example {
|
}
(The cursor is where the pipeline character is..)
Check within Options on the Text Editor/All Langauges/General page. Select "Automatic brace completion."
By the way in 2013 you can search for words like "brace" at the top of the treeview control in Options to find all the pages were "brace" is found.
Answer taken from here.
Try typing
class
then press Tab.
Same goes for interface, if blocks, etc.
If you want to write a property, type
prop
then press Tab.
You can press Ctrl-Enter and it will reposition the closing brace as you expected. Because Ctrl-Enter makes a new line above the current line.
Given the following code example
someMethod(②someArgument①);③
I know moving the cursor from position ①->② shortcut is CTRL+], is there a ①->③ shortcut.
Is there a keyboard shortcut that escapes the brace when cursor is just left of brace (Not with End key).
In Eclipse, It can easily work with Tab key.
(In Visual Studio) - Try Ctrl+Shift+] - That seems to select text to where you might need to be, but if you press the ] again, by itself, it deselects, but leaves the cursor where you appear to want it.
Is that what you're looking for?
I have plenty of experience with Eclipse, and now I'm trying out Visual Studio 2010. I find its formatting somewhat counter-intuitive. Here are some things I'm trying to figure out:
Is there a way to select all text and format/indent it properly, like SHIFT+A SHIFT+I in Eclipse?
Why is it that when I type a line like if (n == 0) {, as soon as I type the opening brace, the text cursor is moved to the beginning of the line? Is this some productivity speedup I'm failing to see?
When I hit ENTER after the aforementioned line, I'd like the closing brace to be put in place automatically for me. How can I do this?
I've looked for hotkey documentation, and it's helped a bit, but this still feels clunky to me.
The Format Document shortcut key combination is Ctrl K, Ctrl D. Since this command is not supported in C++ ( Visual Studio 2010: Why aren't key combinations available?), the workaround for C++ files is to Select All then Format Selection: Ctrl A, Ctrl K, Ctrl F.
On your second and third question, see Creating and Using IntelliSense Code Snippets. Short version: for if, type "if {TAB} {TAB}". Again, this not supported for C++. So if you're in C++, what you're seeing is when you typed typed the { on the line after the if, what the editor did was move the { to the same indention level as the if (not necessarily the beginning of the line), because the coding style it's helping you achieve is
if (n == 0)
{
n = 1;
}
The formatting commands are by default bound to Ctrl+K Ctrl+??. Ctrl+K as the first keystoke, followed by another key stroke that determines the specific formatting option.
Look at the Advanced submenu of the Edit menu. It will show you that
"format selection" is Ctrl+k Ctrl+f
"comment selection" is Ctrl+k Ctrl+c
To format a document in visual studio the key combination is: ctrl-k ctrl-d
just FYI in eclipse it's: ctrl-a -> ctrl-i
not shift-a -> shift-i
I'm sure I'm the only one that actually tried that in eclipse.