Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigating through code with keyboard shortcuts [closed]

For Visual Studio, Ctrl + - is priceless (jump to last position).


I use a lot of keyboard shortcuts in Visual Studio, and also a lot of Alt-key menu navigation.

Ctrl / Shift F3 to repeat search, search backwards

Ctrl F3 to search for the current word.

F12 to jump to the definition of the current word.

Ctrl F to open the search window

Ctrl ] to jump to a matching brace

Shift Ctrl ] to jump to a matching brace and select

I also find I tend to use the ALT-key to navigate the menus. Because you can see the underlines, it makes it easy to learn. example: Alt-E F I (Edit/Find and Replace/Find in Files) takes you to Find in Files. Alt-L then takes you to the scoping drop down. 3 arrow keys takes it to Find in Solution, or 4 takes it to Find in Project.

There's also the bookmarking shortcuts- CTRL K K to toggle a bookmark, CTRL K L to clear them all, CTRL K N for the next and CTRL K P for the previous.

Some of the people I work with really like regions, but I don't, so CTRL M L opens all the regions up. However, I do like to use CTRL M M to collapse a section of code. It's really handy to collapse the current method, select the collapsed method and copy the whole thing to the clipboard. CTRL M O will collapse everything to definitions, which occasionally is nice.


Ctrl + F3 to find the next occurrence of whatever word your cursor is inside of. So if you clicked on the first instance of the word 'occurrence' in my post and pressed Ctrl + F3, it would take you down to the second one.


Alt + Up Arrow and Alt + Down Arrow are amazing commands. They move lines up and down. Saves a ton of keystrokes and you don't have to clobber your clipboard. It even works for multi-line selections.

Alt + Shift + Arrow key allow you to make a block selection. What many don't know is, if you have a vertical block selection (with zero width) and type, it will type into all the lines at the same time. Extremely useful.

If you wish to populate several lines with the same thing you can put it on the clipboard, make a vertical block selection across multiple rows, and paste into all the rows at the same time. This can also work to append to several rows at once, pasting into a selection that is to the right of the existing text.

Ctrl+Del deletes next word. However, if there is space after the cursor, it deletes all the space. Usually what you want when you have the cursor in the right place and the text is off to the right and that next word needs to be pulled over to the cursor.

Ctrl+Backspace deletes the previous word. Not particularly useful, but it's a good under-utilized shortcut. I see people mashing backspace all the time.

Although not strictly a keyboard shortcut, if you hold Alt and click somewhere in the text editor, it will force the cursor to be there. If you type it will automatically put in spaces or tabs appropriately to make that text be there.


F12 = Go To Definition of method/variable cursor is in. Works well combined with Heinzi's Ctrl + - answer to view definition of method then quickly go back to where you were using it.


You can find over 100 answers to this very same question here:

Favorite Visual Studio keyboard shortcuts