A Developer WeBLOG RSS 2.0

As a .NET developer, I spend 80% of my time looking at codes in Visual Studio. I find that with Visual Studio’s default theme is too bright and restraints my eyes easily after prolonged used. Thus, I opted to find a custom theme that has soft contrast that easy to look at. You may think that this is not a very important issue, but the longer your eyes to get tired, the more time you get to work productively. Scott Hanselman has a good list of Visual Studio theme in his site, but unfortunately none of them works for me. Most of the Visual Studio themes in the list has dark background (which is a good thing), but I find that the contrast between the text with the background is too vibrant. Those themes are still a lot better than Visual Studio default theme, but I’m looking more on a softer theme, softer dark background with a not too bright text color.

I went on googling around to try to find a better Visual Studio Theme, then I found this Inkpot theme. I find that this theme has a very good color selection. It has grayish black background, instead of going all black. The font color has matte-like looks, and definitely not bright. Its not a perfect theme, but I think its the best to my preference.

Here is how to change your Visual Studio Selected Settings:

  • Download the InkPot theme and place it anywhere in your hard-drive.
  • On the Tools menu, choose Import and Export Settings.
  • On Welcome to the Import and Export Settings Wizard page, click Import selected environment settings and then click Next.
  • On the Save Current Settings page, select Yes, save my current settings, and then click Next.
  • Browse to the location of your Inkpot theme, select it, and click next.
  • Expand the All Settings, Options, Environment Category, and select the Fonts and Colors settings.
  • Click Finish.

If you’re working with Visual Studio on regular basis, I highly recommend you to change your theme. Its very important to have a less bright, dark background theme as it goes easy on your eyes. Try out the Inkpot theme, it works great for me. You can read more about how to modify Visual Studio Theme Settings here.

NOTE: this theme is for Visual Studio 2008. Credit to the original poster of the Inkpot theme (sorry I’ve lost the link to your website).

RWendi

Tuesday, February 03, 2009 5:00:00 AM UTC |  Comments [0]
VS2008

Code Snippet is a feature in Visual Studio that allows you to have a predefine code, which can be inserted anywhere in your code. It sorts of like a macro, where you can just write the macro name anywhere in your code file and then press the Tab button to replace it with the piece of code you've defined. This feature was first introduced in Visual Studio 2005.

I have to say that I love code snippet. It has saved me huge amount of time. Just about any line of code that I would repetitively write, I put them into a code snippet. One of the cool thing with code snippet is that, it is supported by intelisense. This means, you don't have to type the whole snipet name everytime you want to use it. Just type a the first few characters, select your snippet from intelisense, and then press Tab twice. There you go, you have instant code generation, without having to write any codes.

Code snipet is defined in an Xml document, which has to be named with .snippet extension (e.g. MySnippet.Snippet). Code snippet consists of 2 parts: the header part, and the snippet part. The Header part contains metadata of the snippet, things like the title, shortcut name, description, author, and the types of the snippet. The snippet part contains the actual code that you would like to define in the code snippet. The code snippet itself must be inside a CodeSnippets Xml Node. Here is an example of a code snippet file (The first code snippet is just a template, the second one is an example of a working snippet):

Once you have created your snippet file, you need to place that file inside the "My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippet" folder. Or, alternativelly you could use Visual Studio Snippet Manager to define a new folder to put all your snippet files (Tools -> Snippet Manager).

One cool thing that you can do with code snippet is to define parameters for your code snippet. This allows you to easily changes things inside your code snippet. Lets take the example snippet on the picture above as an example. Rather than hardcoding the string value ("FOO"), we could just create a parameter for that. If you have a snippet with parameter, once your snippet code is written out, the cursor will automatically highlight your parameter so that you can replace the value of your parameter straight away. Moreover if you have multiple parameters, you can use the Tab key to jump from one parameter to another parameter.

To define a parameter, you need to add a literal declaration inside your snippet. In your literal declaration, you need to define an ID for the snippet parameter, which can be used later on inside your snippet code. Lastly, to use a snippet parameter, in the snippet code, you must reference the paramater ID encapsulated with the dollar sign (e.g. $ID$). That's it, thats all you need to do. An ID is the minimum value that you need to have to create snippet parameter, but there are other things that you can define for your snippet parameter, such as: a default value for the parameter and a tooltip value for the parameter. Applying parameter to the snippet example, the final snippet looks like this:

Another cool thing that you can do with code snipet is that, Instead of plain inserting a code, you are able to surround a piece of code with your snippet code. To do this all you need to do is to define a snippet of type "SurroundsWith", and then you need to define the area to place the target code by using the $selected$ value. To use your surrounds with snippet, you have to select a piece of code that you want to surround, then press cntrl+K and cntrl+S, and select the snippet that you want to use. Please note that, you can not use the "surrounds with" snippet by using intellisense. Here's an example of a "SurroundWith" snippet (taken from the default "IF" snippet):

Thats it, I hope you find code snippet to be as usefull as I find it to be.

RWendi

Wednesday, November 05, 2008 8:59:09 AM UTC |  Comments [0]
c# | VS2008

One of my colleague came accross to this file which contains all the default shortcuts of Visual Studio 2008 (c#). I find it very usefull.

c# Visual Studio 2008 default keybindings/shortcuts: [MSDN]|[Download]

RWendi

Monday, November 03, 2008 9:33:44 AM UTC |  Comments [0]
c# | VS2008
All Content © 2010, RWendi