Useful Visual Studio Hotkeys/Tricks
1 07 Sep 2016 04:00 by u/rwbj
Just discovered a really handy hotkey of sorts. A pretty common problem is you need to move text around. For instance, I was just working on synchronizing access to a class which basically came down to adding a bunch of try.. semaphore.wait ... finally ... semaphore.release blocks which is actually kind of annoying to do since you can't just copy-paste it easily as the methods need to go inside the try block.
On an off chance I decided to try something.. and it worked!
If you highlight some text, you can move that text up/down by holding alt while pressing up or down. So in this case imagine you have:
void SomeMethod()
{
SomeNonsyncStuff...
}
You can paste the default try...finally semaphore block above the SomeNonsyncStuff stuff then highlight the SomeNonsyncStuff and use alt+arrow keys to bring it up into the block as appropriate. Turned a 15 minute job for a fairly large file into a 1 minute job!
Another trick that I think most people probably know is column highlighting. Holding alt while highlighting will highlight vertically from the current mouse horizontal offset instead of starting at the beginning of the line. Also works in notepad++.
This got me wondering. I've been using visual studio for many years and never knew about this one. Wonder what else I'm missing! Do you know any other uncommonly known hotkeys or tricks?
0 comments
No comments archived.