79

I'm starting to feel the need to run fastly through code with keyboard shortcuts, to arrive faster where I want to make any changes (avoiding use of mouse or long times holding , , and ).

I'm already using some:

  • Home - first position in current line

  • End - last position in current line

  • Ctrl + Home - first line of the entire code

  • Ctrl + End - last line of the entire code

  • Page Up - same vertical position, one screen above

  • Page Down - same vertical position, one screen below

  • Ctrl + Page Up - first line in current screen

  • Ctrl + Page Down - last line in current screen

  • Ctrl + / - skipping word per word

What have you got ?

I use Visual Studio. (but I'm open to any answer, as I maybe can use others soon)

obs: I've searched through stackoverflow and didn't find a nice question with this content, nor a list of keyboard code searching. If it's repeated, I'm sorry for not finding it, I'm here in my best intentions.

This question is NOT about any shortcuts, and not only about visual studio, it's about running through code with shortcuts.


Answers that suit the question so far:

  • Ctrl + - - jumps to last cursor position

  • Ctrl + Shift + - - jumps to next cursor position

  • Ctrl + F3 - Jumps to next occurance of the word the curson is in

  • Shift + F3 - Same as the above, backwards.

  • F12 - Goes to definition of method/variable the cursor is in

  • Ctrl + ] - Jumps to matching brace and select

I'll ad more as there are answers.

colton7909
  • 824
  • 12
  • 16
Marcelo
  • 3,371
  • 10
  • 45
  • 76

10 Answers10

38

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

Jasper
  • 2,166
  • 4
  • 30
  • 50
Heinzi
  • 167,459
  • 57
  • 363
  • 519
15

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.

Bob Bryan
  • 3,687
  • 1
  • 32
  • 45
Pete McKinney
  • 1,211
  • 1
  • 11
  • 21
13

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.

doug65536
  • 6,562
  • 3
  • 43
  • 53
13

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
Ben Collier
  • 2,632
  • 1
  • 23
  • 18
4

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
rosscj2533
  • 9,195
  • 7
  • 39
  • 56
2

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

Favorite Visual Studio keyboard shortcuts

Community
  • 1
  • 1
DOK
  • 32,337
  • 7
  • 60
  • 92
  • it's not the same.. it's about ANY shortcut.. i'm searching for keyboard browsing shortcuts. – Marcelo Dec 11 '09 at 15:22
  • @MarceloRamires: It's not the _same_, but your question is a subset of the other question. You might not be able to use ALL of the shortcuts, but you should be able to search through that list and find the ones that are appropriate for your situation. – Seth Petry-Johnson Feb 19 '10 at 17:44
  • So let's flag "Common programming mistakes for PHP developers to avoid?" as a dupe because "Common mistakes in web development" exists.. perfect subset.. haha, just kidding. It's just that I find it too annoying moving my hand towards the mouse just to go somewhere near but hardly reachable through common commands.. Thanks! – Marcelo Mar 03 '10 at 20:19
2

Alt + , Alt +

Will jump to next, previous code block (Method, class, etc.) Might only be in ReSharper.

Jasper
  • 2,166
  • 4
  • 30
  • 50
1

On Visual Studio, but using a lot of the ReSharper shortcuts. A few that I use heaps:

  • Ctrl + N - Go to type

  • Ctrl + Shift + N - Go to file

  • Ctrl + Shift + Alt + N - Go to symbol

  • Ctrl + F12 - Go to method (in current file)

  • Ctrl + B (or Ctrl + Click) - Go to declaration

  • Ctrl + Shift + T - Go to type declaration

  • Alt + F7 - Find usage (or go to usage, if only one)

For the first four, resharper gives me a dropdown menu with options, filtered as I type, and they all support wildcards (*), and camel-hump navigation (typing SPI filters to just items such as SinglePassengerInfo, etc)

Jasper
  • 2,166
  • 4
  • 30
  • 50
David Hedlund
  • 128,221
  • 31
  • 203
  • 222
1

Honestly, I long for the day when VisVim gets to a good enough point to get me to buy it for Visual Studio (<3 VI keyboard commands).

Anyway, the command that I use the most in Vis Studio is Ctrl + D, which I have mapped to Edit.GotoFindCombo

Jasper
  • 2,166
  • 4
  • 30
  • 50
erik
  • 3,810
  • 6
  • 32
  • 63
  • so you select a word and press ctrll + d and it shows you the next one ? – Marcelo Dec 11 '09 at 18:21
  • @espais Have you tried Viemu? http://www.viemu.com/ I've used Viemu + Resharper since June and it makes a drastic difference in the speed I can navigate and manipulate code. – statenjason Dec 11 '09 at 18:37
  • sorry, yea i meant viemu...i've tried it and liked it enough, but when i tried it there were too many commands missing for me to justify buying it – erik Dec 11 '09 at 22:15
  • @Marcelo: no, it just puts the focus on a quick find combo box...i like it better than having to wait for the find dialog to popup! – erik Dec 11 '09 at 22:15
  • This is an old question, as it this answer, but I have been using VsVim with great success https://marketplace.visualstudio.com/items?itemName=JaredParMSFT.VsVim – helios456 Jan 15 '19 at 14:13