Advertisment

VS.NET: Tips ‘n’ Tricks

author-image
PCQ Bureau
New Update

Incremental Search: It’s a very powerful feature. As the name implies, it lets you search incrementally. Say you have strings ‘Hell,’ ‘Hello’ and ‘Hello World’ in your code. Press Ctrl + I and start typing–VS.NET will start searching as you type in. So as you finish typing Hell, you will see Hell highlighted in your code. If you want to jump another instance of Hell, just press Ctrl + I again or if you want to search for Hello, keep typing in Hello. All this will make a lot more sense if you fire up VS.NET and give it a shot. It comes in very handy for jumping between functions in long code.

Advertisment

Command Window: If you are good with a keyboard, chances are that you hate fiddling with your mouse. In that case, Command Window is the right solution for you. All common VS.NET commands like open file are accessible from a small console interface built right into VS.NET. Summon the genie by pressing Ctrl+Alt+A. You should be in a command window with ‘>’ prompt. Type: open file C:\YourPath\Yourfilename.cs and voila, the file opens. What is cool about this is that as you are typing in Path, ‘intellisense’ will kick in and will try to help you complete the path with minimum typing. Try a few more commands like ‘Close,’ ‘CloseAll’ and the ubiquitous ‘Exit.’ 

Prefix your commands with > for them to be recognized as commands and not search strings

Now if you thought that was cool, check this. In your Find Command bar, instead of typing your search string, just type > File Open. Your Find ‘textbox’ turns into a mini-command window. You can do all that you do in command window here as well.

Advertisment

Conventional selection happens as depicted above

Just make sure that you prefix your commands with > (for them to be recognized as commands and not search strings)



Since we are still on the topic of command prompts, most of the common commands, have some handy macros defined. So Open Project has been abbreviated to just op, try typing in ‘op FileName.csproj.’ Try another command,

‘Macros.Samples.Utilities. TurnOnLineNumbers’ (make sure you have a C# file open (and that you are in code view). Also try its antithesis, Macros.Samples,Utilites.TurnOffLineNumbers. We are using some of the macros built into VS.NET. Since these macro names are such a pain to type, you can alias them. For this, take a look at the commands below:

Advertisment

>alias lon Macros.Samples.Utilities.TurnOnLineNumbers



>lon


>alias loff Macros.Samples.Utilities.TurnOffLineNumbers


>loff

For rectangular selection, hold Alt while selecting text

Basically you are defining lon as an alias for Turning On Line Numbers and loff as an alias for turning off line numbers. You can play with all the macros by going to Tools > Macros > Macro Explores. Just keep in mind, that macros don’t fire when open. So close the Macro explorer, before writing the macro.

Advertisment

This one might seem a little lame, but many people don’t know that VS.NET pastes code in RTF. VS.NET retains the color and formatting for text copies from within an editor. You can place colorized snippets of code in mail, documents and slides. Color is also supported when printing.

Ever wanted to select an arbitrary rectangular area of text in your editor? Hold down Alt key when selecting text and you’ll get a rectangular selection. The following screenshots should make what I am saying clear:

VS.NET also has a nifty full screen mode, where it is the only windows visible, minus any tool windows. Just press Alt+Shift+Enter to enter full-screen mode, press Alt+Shift+Enter again to return to normal mode

Advertisment

If you liked the Lord of the Rings, you’ll love this one! The copy and cut operations that you make in the editor, are collected in a clipboard ring (it’s a ring of 20 rotating items). Press Ctrl + Shift + V repeatedly, to rotate the ring by sifting through the pastes. You can look at the clipboard ring by clicking ‘Clipboard Ring’ on the 

Toolbox:



In fact you can even drag and drop items from the clipboard ring into your code. Also, if you don’t have anything selected in text window, and you press Ctrl+C, the current line is copied onto the clipboard. 

Advertisment

If you have verbose variable names, and soon find your self-stifled for horizontal space, you can toggle word wrap by pressing Ctrl+R twice. 

No_More_Horizontal_ Scroll ing (or NoMoreHorizontalScrolling, depending on your personal preference.

Advertisment

When using Find and Replace, you can not only search for text, but also for Regular Expressions. Just check the ‘Use Regular Expressions’ checkbox in the find dialog. 

Finally, VS.NET allows you to save your code files as Unicode. So it’s perfectly ok to have variable names in Hindi or Tamil or any other Indic language supported by Windows XP (not just strings, even variable names). So don’t be amazed if you find yourself writing code that looks like as above.

Deepak Gulati, India Communities Specialist, Microsoft

Advertisment