Here are two ways to search within a document that won’t open the search dialog in Visual Studio 2010. The first one is also useful for 2013.
Incremental search (Ctrl-i): Ctrl-i will start an incremental search. In Visual Studio 2010 this won’t even open the search dialog. Your search pattern will be displayed on the bottom bar in 2010 and in the standard search box in 2013. You can cycle through various entries by continuing to press Ctrl-i.
I often use incremental search to quickly jump to a specific location on the same line or a nearby line. For example if I want to jump to the word string I can just press Ctrl-i followed by the first few characters of the words I am looking for, in this case: st and I’m usually there. By using this feature I am able to prevent using the mouse or the arrow keys to move the cursor.
This is a big gain as taking your hands away from the keyboard has a huge impact on your workflow and the arrow keys are a slow way to move around (even with shift-arrow key).
Keep in mind that as the distance you need to travel increases, you’ll tend to get more and more misses with this strategy and might need to keep repeating Ctrl-i too much.
Search for the word under the cursor (Ctrl-F3): This next one is specific to Visual Studio 2010. If you want to find other occurrences of a specific word just move your cursor to it and then press Ctrl-F3 which will automatically send you to the next occurrence. Again this will not bring up the search dialog, which would then necessitate at least one more click to confirm.
You can continue pressing F3 (no need for the Ctrl key) to move to the other occurrences of the same word within the current file.
This is particularly useful when you are already positioned on the word you want to search, say a variable or function, and contrary to Find all references it will also find commented out instances.
In Visual Studio 2013 search has been improved which rendered this shortcut obsolete. You can still press Ctrl-F3 which will have the same behaviour has Ctrl-F. F3 will also cycle to the next search hits.
In the same series:
Delete things faster in Visual Studio with these two weird tricks
Here are two nifty keyboard shortcuts in Visual Studio:
Cut whole line (Ctrl-L): This will cut/delete the whole line and send it to the clipboard. This is useful in two situations.
First, it let’s you remove a whole line in a single action reliably.
For white space lines, depending on the line configuration, using delete or backspace might necessitate more than a single key stroke per line. Ctrl-l always does it in one action.
For non white-space lines Ctrl-l prevents you from having to select the whole line and then deleting it, saving you again one action. Every action saved counts.
The second situation is when you want to select a whole line, cut it, move and then paste it. With Ctrl-l you can reduce this from 4 actions to 3.
When using Ctrl-l if you overwrite your current clipboard you can do a Ctrl-Shift-v to cycle through your clipboard history.
Delete next word (Ctrl-Del): This is a universal shortcut that works for many programs but I have included it here since I learned about it recently. This will delete the whole word in front of you instead of just a single character.
In the same series:
Search for things faster in Visual Studio with these two weird tricks
Not stopping the build on the first error is a feature that allows you to get more errors in a single build pass and that most younger developers take for granted.
While this is sometimes the best possible behaviour, there are situations where this is not desirable. If you have a large solution with many layered project dependencies and you are working on one of the bottom layer you will eventually end up with loads of cascading “Cannot find referenced assembly” errors. These do not give you any information beside the fact that assembly X did not compile and assembly Y needs assembly X and can’t find it.
Something you already know since you just saw the message when assembly X failed.
One the solutions I am working on is a large solution where compilation is painfully long. Combine this to the fact when pressing Ctr-Break to stop this chain of “Cannot find referenced assembly” I must wait a few seconds for the computer to break out of the resource heavy operation that such a compilation represents and you get a dreary situation.
I had previously tried a macro for this (which you can find many variations online), but my main gripe was that it changed the behaviour of Visual Studio to always stop after the first project had encountered errors. What I wanted was to be able to easily toggle this to reflect my current situation in Visual Studio.
My search for something better lead me to the Visual Studio add-in: StopOnFirstBuildError in Visual Studio’s add-in gallery. You can also read the author’s blog post on the subject: Stop Build on first error in Visual Studio 2010.
Basically the most important feature of this add-in is the ability to easily toggle the Stop build on first error functionality via an item in your build menu.
Now you can have the best of both worlds.