Favorite Visual Studio keyboard shortcuts [closed]

2019-01-03 11:35发布

What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse!

One per answer please.

30条回答
Root(大扎)
2楼-- · 2019-01-03 11:48

Ctrl+Space, Visual Studio gives the possible completions.

查看更多
爷的心禁止访问
3楼-- · 2019-01-03 11:48

One that other editors should take up: Ctrl+C with nothing selected will copy the current line.

Most other editors will do nothing. After copying a line, pasting will place the line before the current one, even if you're in the middle of the line. Most other editors will start pasting from where you are, which is almost never what you want.

Duplicating a line is just: Hold Ctrl, press c, then v. (Ctrl+C, Ctrl+V)

查看更多
Viruses.
4楼-- · 2019-01-03 11:51

By usage, the pair:

  • Ctrl+Enter: insert blank line above the current line.
  • Ctrl+Shift+Enter: insert blank line below the current line.
查看更多
We Are One
5楼-- · 2019-01-03 11:53

Haven't seen this one ...

Ctrl + Up

Ctrl + Down

Scrolls the window without moving the cursor.

查看更多
欢心
6楼-- · 2019-01-03 11:54

One that I use often but not many other people do is:

Shift + Alt + F10 then Enter

If you type in a class name like Collection<string> and do not have the proper namespace import then this shortcut combination will automatically insert the import (while the carret is immediately after the '>').

Update:

An equivalent shortcut from the comments on this answer (thanks asterite!):

Ctrl + .

Much more comfortable than my original recommendation.

查看更多
神经病院院长
7楼-- · 2019-01-03 11:54

Here is a list that I use frequently:

Ctrl + I: for progressive search. If you don't type anything after I, and keep pressing I (holding the Ctrl key down), it will search the last item you had searched. Ctrl + Shift + I will reverse search. You might also want to use F3 (and Shift + F3) once some search string is entered.

Ctrl + K Ctrl + C: For commenting highlighted region. If nothing is highlighted, current line will be commented. Naturally, you can just hold Ctrl and press K, C in succession.

Ctrl + K Ctrl + U: For uncommenting highlighted region. Works like above.

Ctrl + /: Will take the cursor to the small search box on top. You can type ">of filename" (without the quotes) to open a file. Very useful if your project contains multiple files.

Ctrl + K Ctrl + K: Will bookmark the current line. This is useful if you want to look at some other part of code for a moment and come back to where you were.

Ctrl + K Ctrl + N: Will take you to the next bookmark, if there are more than one.

Ctrl + -: Will take the cursor to its previous location

Ctrl + Shift + -: Will take the cursor to its next location (if it exists)

Ctrl + Shift + B: Build your project

Ctrl + C: Although this does the usual copy, if nothing is highlighted, it copies the current line. Same for Ctrl + X (for cut)

Ctrl + Space: Autocomplete using IntelliSense

Ctrl + ]: Will take you to the matching brace. Works with all kinds of braces: '(', '{', '['. Useful for big blocks.

F12: Will take you to the function definition/variable definition.

Alt + P + P: Will open up project properties. Although not many use this, it useful if you want to quickly change the command line arguments to your program.

F5: To start debugging

Shift + F5: To stop debugging

While debugging, you can use Ctrl + Alt + Q to add a quick watch. Other debugging shortcuts can be found in the debug drop down menu.

查看更多
登录 后发表回答