Shortcut: Apply cut or copy commands to blank lines when there is no selection

When I'm doing a lot of query editing, I often get a bit mesmerized, particularly if there's a lot of manual copy and paste or cut and paste going on.

One thing that often drives me crazy is when I use Ctrl-C (ie: copy) when I meant to use Ctrl-V (ie: paste). Invariably, I do this when I have nothing highlighted at all. So not only did I not get the value pasted, I just copied an empty value into the clipboard.

But SQL Server Management Studio (SSMS) has your back on this. (And so does Visual Studio)

In Tools, then Options, then Text Editor, then Transact-SQL, under the General tab, there's an option for Apply Cut of Copy commands to blank lines when there is no selection.

The default is that it works as expected (like you don't want it to), but if you uncheck it, you might have just saved yourself some annoyance.

If I'm working with this code:

and I highlight the word DECLARE and hit Ctrl-C, then move to the blank line and hit Ctrl-C instead of Ctrl-V, I'd have just lost my first clipboard item. With this option unchecked, I can just smile, and hit Ctrl-V again, and it will still paste:

2 thoughts on “Shortcut: Apply cut or copy commands to blank lines when there is no selection”

  1. Even better is Ctrl-Shift-V

    If you accidentally copy something, you don't need to go back and re-copy what you REALLY wanted, you can just press Ctrl-Shift-V. Keep holding Ctrl-Shift while pressing V, and you'll cycle back through previous copies, and can paste any one of them.

    This paste ring-buffer trick can really save a lot of time. You can quickly copy three different things, then go to another tab or another place in a long script, and paste all three (presumably non-contiguous) items.

Leave a Reply

Your email address will not be published. Required fields are marked *