#93 Use undo to jump the cursor back to the last insertion point

In a previous tip, we learned more than we ever wanted to know about go-back markers.  Insertion points are slightly different.  They are similar to the go-back markers, but it is anywhere you click the mouse or jump the cursor to.  The go-back marker 10 line rule doesn’t apply.

Move caret command in the undo list

To give it a try, just click somewhere, then click somewhere else (or do a find or a goto if you’re using the keyboard), then press undo.  You’ll move back to that previous location.

The option can be found at Tools – Options – Text Editor – General

Include Insertion Point Movements Tools Option

#92 Jump to the beginning of some selected text when hitting escape

I hope this tip’s title makes sense.  The idea is that you select some text and then hit escape.  Where do you want the cursor to go? 

Selected text with the selection anchor and cursor circled

If you want it to stay where it is, that’s the default behavior.  But if you want it to jump to the beginning of the selection (i.e. the selection anchor), you need to go to Tools – Options – Text Editor – General and check the Go to selection anchor after escape.

Go To Selection Anchor After Escape Tools Option

#91 fun with the Find Combo Box

It’s time for an old favorite from the Visual Studio 2005 days…

Remember How to search using the Ctrl+D Window from one of the earlier tips?  Now let’s have a little more fun…

Press Ctrl+D to go to the Find Combo Box and then…

Goto a line – type the line number and press Ctrl+G (i like showing this off as how you can do a "go to line" without popping up the go to dialog box) 
Goto a file – type the name of the file (either in your project or on the INCLUDE path)and press Ctrl+Shift+G
Set a breakpoint on a function – type the name of the function and press F9
Get help – type the keyword and press F1

And to continue from yesterday’s tip on command aliases

To get a callstack – type “> kb”
To go to a webpage – type “> nav http://www.microsoft.com

 

#90 Create a command alias

To create an alias, open up the Command Window (or anywhere you can type in VS commands) and type in something along the lines of

alias GobblesGobblesGobbles help.about

Command Window creating aliases

and now running GobblesGobblesGobbles from the VS command window will pop up the Help About menu.  I will award bonus points if you can figure out the Gobbles reference.  =)

But let’s explore a more practical application….

alias se View.SolutionExplorer

Now you can just type se to jump to the solution explorer.  For this particular example, the idea is you can be typing in the editor, press Ctrl+/ to jump to that Find window that can act as a command window, and type in se.

Actually, you’ve probably already used one of the predefined aliases before. Debug.Print is alias to ‘?’.  To see the full list of aliases, type in

alias

predefined aliases

Lastly, to reset your command window aliases back to defaults, type in

alias /reset

Reset aliases warning prompt

or just simply use the /delete switch to delete a particular alias, like alias se /delete.

 

#89 Run external executables from the VS command line

The command Tools.Shell will run an external executable out of process from VS.  To run, it is basically

Shell <executable>

But of course, we got optional arguments…

Shell [/commandwindow] [/dir:folder] [/outputwindow] <executable> [/args]

/commandwindow (or /c) – to display the executable’s output in the command window

/outputwindow (or /o) – to display the executable’s output in the output window

/dir:folder – specifics the working directory

For example,

Shell /o /c xcopy.exe c:\users\saraf\documents\cmdwinlog.txt c:\users\saraf\pictures

will display the xcopy output in the output window.

output redirected to the output window