Visual Studio Minimize regions shortcut? [duplicate] - visual-studio

This question already has answers here:
Command to collapse all sections of code?
(21 answers)
Closed 8 years ago.
Is there a shortcut key in Visual Studio that will minimize all of the regions or + signs so that I don't have to go through and click each one individually?

C-m, C-o // collapse all
C-m, C-l // expand all
C-m, C-m // collapse, expand one
Where C is short for Ctrl. You can find more shortcuts at the msdn site
You can find the commands by going to Keyboard Options under the Tools menu, they are mapped to these commands
Edit.CollapseToDefinitions (C-m, C-o),
Edit.ToggleOutliningExpansion (C-m, C-m) and
Edit.ToggleAllOutlining (C-m, C-l)
If you are using Visual Studio Code the commands are similar but work differently. The commands are roughly these
C-k 2 - Fold Level 2
C-k C-j - Unfold all
C-k [ - Unfold recursively (unfold where the caret is)
You can search for Fold or Unfold commands (using C-S-p) to find all of them.

Ctrl + M,M - expand/collapse at caret
Ctrl + M,O - collapse all in document
Ctrl + M,L - expand all in document

Ctrl + M, Ctrl + M
You can perform this on a selection too.

Related

Is there a way to do multiline editing a-la Visual Studio in Sublime?

Visual Studio allows selecting a vertical piece of text, and then editing it. One has to hold Shift + Alt and move the cursor up-down left-right to make the selection.
I know there is Ctrl + D multi-cursor thing in Sublime, but it's not quite the same.
So is there a way to do the multi-line editing a-la Visual Studio in Sublime?
Move cursor where you want, hold ctrl + shift press ↓ a few times.
Press tab, then ← twice, type "Hello World,",
Press esc to leave multi-line mode.
You also can perform "square selection" using your mouse middle button.
Answer: Standard way: Ctrl + Alt + Cursor (which flips the screen orientation on my laptop). The way that works: Keyboard Column Selection for Sublime Text 2 on Windows

Is there a way to delete a line in Visual Studio without cutting it?

I want to delete a line just like hitting Ctrl + X without anything selected, but without saving the line to the copy stack. Is this possible?
I'm using Visual Studio 2010.
Edit.LineDelete is the name of the command. By default it's bound to Ctrl + Shift + L, but you can give it whatever you like in Tools | Options | Keyboard.
Edit: Corrected default shortcut info.
Ctrl + Shift + L will delete the line and not copy to the clipboard.
I mapped Ctrl + L (Global) to Edit.LineDelete. Otherwise, the shortcut key is Ctrl + Shift + L, which is awkward. Go to Tools > Options > Environment > Keyboard as shown below.
Correction in my answer
Ubuntu 16 &
Visual studio Version: 1.30.1
To cut line
Shift + del
To delete line Shift + Ctrl + k
CTRL + L (Visual Studio 2019 Windows)
Its Cmd + Shift + K on mac by default.
But it can be modified according to user needs from the settings (Preferences -> Keyboard Shortcuts) -> search for Delete Line key value.
Valid Answer By 2022 for VS Code (with image)
All the above answers regarding Ctrl + Shift + L are now deprecated.
The correct default behavior is Ctrl + Shift + K
(⌘ + Shift + K if you're a MAC user).
To change this default behavior:
1- Go to File > Preferences > Keyboard Shortcuts (OR click Ctr+K Ctrl+S)
2- Type in the search bar delete line
Here you will find the corresponding behavior. You can change it just by double-clicking on it and pressing any desired combination of keys on your keyboard (pay attention of conflicting shortcuts).
By default, if you are using the C# default profile, you can delete a line using Ctrl + Shift + L.
You can customize this using Tools->Customize. Select "Keyboard". Look for the command Edit.LineDelete to assign it to whichever keyboard shortcut you like.
Source
If you got here looking for an answer for Visual Studio Code the default shortcut is:
ctrl + shift + K for Windows
⌘ + shift + K for MacOS
However, you can change on File > Preferences > Keyboard shortcuts
{
"key": "ctrl+shift+delete",
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
}
Source
none of the above answers worked for me. to delete a line in visual studio code use :shift+del
All the answers were helpful but didn't seem to work for me.
So I found the solution --> for Visual Studio 2017 (and certainly 2019):
Tools > Options > Environment > Keyboard > on the right pane select Edit.LineEdit.
Below there is a ComboBox Use new shortcut in: with Global written --> Change it to Text Editor.
On the right there is a Text input Press shortcut keys:, so use the shortcut of your choice.
Then click on Assign PushButton on the right (otherwise it won't be applied).
Finally > OK.
You can now open a .CPP file and use your shortcut to remove a line.
On Visual Studio 2019 for Mac, it's CTRL + K to cut the whole line by default.
Here is a url for the keyboard short cut reference for windows:
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
For windows: Ctrl + Shift + k
The other answers are specific to Visual Studio, which is what was requested by OP, however if anyone is looking for a more generalized way to do this for most Windows programs, you can also Triple-Click to select any block of text, then just press the Delete key. This works for any Windows text editors or TextBoxes, including password boxes, search boxes, browser web address boxes, etc. For text editors such as Visual Studio, a block of text is typically one line of code. Obviously you can do other things too, such as triple-click to select a line of code, then Ctrl-X, Ctrl-V to cut/paste, etc, or just triple-click and type over it to replace a line.

Visual Studio 2010 Keyboard Shortcut Chords

I started out with VB6 default shortcuts where Ctrl + R brings up the Solution Explorer window.
Now when I hit Ctrl + R I see a status message saying that VS is waiting for me to hit the next sequence in the chord, suggesting to me that I have shortcuts that begin with Ctrl + R but require another keystroke.
This suggests to me that having one or more shortcut sequences that begin with Ctrl + Rinvalidates the Ctrl + R shortcut, which I can understand, but the question is, how do I find what those command are so I can assign a different sequence to them?
Also, shouldn't VS warn me when assigning the first chord shorcut that begins with Ctrl + R that this will invalidate my Ctrl + R shortcut or, it should clear it out so Ctrl + R is no longer a shortcut for the Solution Explorer window.
Anyway, I guess the question is how do I locate the commands that begin with Ctrl + R so I can change them so they dont collide with my Solution Explorer shortcut Ctrl + R?
In VS 2010, Tools | Options | Environment | Keyboard gets you to the right place. Now, put the cursor in Press shortcut keys, and press the keys you are interested in (so Ctrl + R). The Shortcut currently used by dropdown will then show you all the shortcuts that currently involve the keys you have pressed.
I agree it would be a 'nice to have' for VS to warn about overlapping shortcuts, but note that different shortcuts can have different scopes of effect (in the Use new shortcut in dropdown), so this might not be as easy as it sounds.
The keybindings poster from MSDN might be helpful. It looks Ctrl + R behaves differently depending on if you are debugging or not.
Have a look at IntelliCommand Plugin. This helped me out a lot in learning and remembering the chrod combinations.
Also Learn the shortcut Plugin is pretty cool too.

What are your most frequently used shortcut keys in visual studio? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Recently , I found some shortcut key really helpful which I never used before .
Such keys like F7 ,F3 ,Ctrl+g help me a lot when editing and debuging.
What are your most frequently used shortcut keys in visual studio?
including Resharper's shortcuts:
Ctrl-Shift-B (build)
F12 (go to definition)
Shift-F12 (find usages)
Ctrl-- (go to last location)
Alt-Shift-L (go to current file in the solution explorer)
Alt-\ (find member)
Ctrl-T (find type)
Ctrl-Shift-T (find file)
Shift-Esc (close current dialog)
Ctrl-Shift-S (save all files - VS tends to forget)
EDIT: added explanations
I always use the debugging keyboard shortcuts - F9 (toggle breakpoint), F10 (step over) and F11 (step into). I can't believe that some of my coworkers actually use the toolbar buttons for this - it's insanely more efficient to use the shortcuts.
Standard VS keys of F12 for going to the definition and then CTRL+- to go back to where I was before that.
Probably the two shortcuts that get me around VS and my code quicker than any other.
Ctrl + . for bringing up the smart tag for adding namespaces, renaming/refactoring, etc.
I also remapped Ctrl + B to build, Ctrl + Shift + P to Build Selection (in a sense, Build Project) and Ctrl + W to close window.
CTRL+K CTRL+C for comment selection and CTRL+K CTRL+U for uncomment selection (They may be mapped to CTRL+E CTRL+C and CTRL+E CTRL+C in some standard keyboard mappings, but the first two will generally still work...)
The most used keyboard shortcut is Ctrl-Tab to switch between tabs.
Another one I use alot is Ctrl-I to start incremental search.
Two more:
Alt+Ctrl+C for Call Stack
Alt+Ctrl+I for Immidiate window
(Both helpful while debugging)
The list is endless. To maximize readble code space, I've removed all my toolbars. If I want to do it, I have to know the keyboard shortcut for it.
Aside from the basics, I constantly use things like Ctrl-M,O, Ctrl-K,C, Ctrl-K,U, Ctrl-K,D, Ctrl-Alt-E, Ctrl-Alt-P. I have also made a little smiley-face button for "Remove and Sort Usings" because navigating through the right-click menu takes too long and it doesn't have a hotkey that I know of.
Ctrl+Shift+F9 to delete all the break points in a solution. Very handy when people leave them spattered all over the solution!
Shift + F6 to build current project, Shift +F5 to stop debugging
I use many, but most useful I think is
CTRL+K Kfor setting a bookmark
and CTRL+K N for going to next bookmark and CTRL+K P for previous
CTRL+D and then ">of $filename" (open filename),
CTRL+K+C (comment selection),
CTRL+K+F (format),
CTRL+X and CTRL+C on a line to cut
or copy the entire line
I use the bookmark shortcuts alot: Ctrl-K Ctrl-K to create a bookmark, Ctrl-K Ctrl-N to cycle through them.
Ctrl-Shift-B to build is probably the most executed though.
Ctrl + B
which for me is build current project.
I use it less in VS2008 SP1 with the error highlighting so
Ctrl + D
which for me is Go To Definition is starting to edge it out.
I never can remember shortcuts, but Ctrl + - . is one of the few I can remember and use often. With Resharper installed, Alt + Enter is Ctrl . on steroids. Both intelligently resolve a variety of errors or refactorings.

Visual Studio 2008 - jump to line number shortcut

I can go to a specific line number by double clicking in the status bar in Visual Studio. Is there a keyboard shortcut that does the same thing?
Ctrl + G
Check out all the keyboard shortcuts at:
http://www.microsoft.com/downloads/details.aspx?familyid=e5f902a8-5bb5-4cc6-907e-472809749973&displaylang=en
Ctrl + G works for me.
If it doesn't work for you, you can always map whatever shortcut you want under Tools | Options | Environment | Keyboard.
EDIT: Yes, as #Brian mentions, the command in this case is Edit.GoTo
I just realised that the default in C# settings for this command is Ctrl + G, whereas in VB Settings, there is no default keyboard short - it's mapped to show the immediate window - strange I think. I swapped the mappings so that the two environment behave the same.
Every IDE or even text editor I have ever used either uses Ctrl + L or Ctrl + G for this purpose.
I assume this could stand for Ctrl + Line or Ctrl + Goto
Yep Ctrl + G.
From this answer you can get a nice Shortcut poster.

Resources