July 29, 2015 by Kenneth Fisher
I love keyboard shortcuts. I recently mapped a keyboard shortcut to Change Connection and thought I would share some of my other favorites.
- Shft+Arrow keys (sometimes + Ctrl): Highlight blocks of code. Adding in the control key moves you a word at a time rather than a single character. This one is a basic keyboard shortcut/command that is used before a bunch of the others.
- Ctrl-C, Ctrl-V and Ctrl-X: Copy, paste and cut. I’m guessing most, if not everyone, reading this will already know about these but I use them so often I felt they deserved a mention.
- Ctrl-Shft-U, Ctrl-Shft-L: Convert all of the highlighted text to upper case or lower case. If you are a formatting nut like me then you will probably find these particularly handy.
- Ctrl-R: Hide or display the results pane. I sometimes hit this one by reflex trying to expand my work space (by hiding the results pane) without noticing the fact that the results pane was already closed.
- Ctrl-T & Ctrl-D: Shift between text output and grid output. I like the grid output in general but need the text output when I’m using things like sp_helptext.
- Ctrl-K then Ctrl-C, Ctrl-K then Ctrl-U: These comment or un-comment every line highlighted or partially highlighted.
- Ctrl-E: Execute the currently selected text or all of the text in the query pane if nothing is selected.
- Ctrl-Z, Ctrl-Y: Undo and redo changes.
And here are my top two favorites currently. The first one I learned recently and was the inspiration for this post and the second I actually learned while writing it.
- ALT: Used with the mouse or with shift+arrow keys it lets you select a vertical line or a block. From that point you can type the same thing to multiple lines or copy and paste blocks of code. See an awesome example by Erik Darling (b/t) of this here.
- Ctrl+Space: Open up a context sensitive suggestions dropdown. Type USE then Ctrl+Space in the space after it to see what I mean. For someone working with a lot of instances where you can’t remember all the database names (or table names for that matter) this is going to save me some time! From what I can tell this is SSMS 2012 and up
This is by no means the complete list. This is just a short list of some of my favorites. For a more complete list follow this link: SSMS: The Query Window Keyboard Shortcuts