Nice VS 2008 Code Editing Improvements
I've blogged in the past about some of the text editor improvements in VS 2008 that have been made for JavaScript intellisense and CSS style intellisense.
Recently I was looking over the shoulder of someone writing some code, and saw them using some other new text editing features that I hadn't seen before ("wait - how did you just do that?").
Below is a non-exhaustive list of a few new code editing improvements I've learned about this week. I'm know there are many more I don't know about yet - but I thought these few were worth sharing now:
Transparent Intellisense Mode
One of the things I sometimes find annoying with intellisense in VS 2005 is that the intellisense drop-down obscures the code that is behind it when it pops-up:
With VS 2005 I often find myself needing to escape out of intellisense in order to better see the code around where I'm working, and then go back and complete what I was doing. This sometimes ends up disturbing my train of thought and typing workflow.
VS 2008 provides a nice new feature that allows you to quickly make the intellisense drop-down list semi-transparent. Just hold down the "Ctrl" key while the intellisense drop-down is visible and you'll be able to switch it into a semi-transparent mode that enables you to quickly look at the code underneath without having to escape out of intellisense:
When you release the "Ctrl" key, the editor will switch back to the normal intellisense view and you can continue typing where you were in the Intellisense window.
This feature works with all language (VB, C#, and JavaScript). It also works with HTML, XAML and XML based markup.
VB Intellisense Filtering
The VB team has made some nice improvements to intellisense that make it much easier to navigate through APIs.
Intellisense completion now automatically filters the member list available as you type to help you better pinpoint the API you are looking for. For example, if in an ASP.NET code-behind page you type "R" it will show the full list of types and members available (with the selection starting in the "R" list):
When you type the second character of what you are looking for (in this case "e"), VB will automatically filter to only show those types that start with "Re" and highlight the most likely option:
When you type the "s" it filters the list even further:
When you type "p" it filters down to just the one option available:
I find this cleaner and more intuitive than the previous model that always showed everything in the drop-down.
VB LINQ Intellisense
I've done several posts in the past about LINQ and LINQ to SQL. Both VB and C# obviously have full support for LINQ and LINQ to SQL. I think the VB team in particular has done some nice work to provide nice intellisense hints to help guide users when writing LINQ statements in the editor.
For example, assuming we have a LINQ to SQL data model like the one I built in Part 2 of my LINQ to SQL series, I could use the VB code editor to easily work with it. Notice below how VB automatically provides a tooltip that helps guide me through writing the LINQ query syntax:
I can then start writing my query expression and the VB intellisense will guide me through creating it:
The above expression retrieves three column values from the database and creates a new anonymous type that I can then loop over to retrieve and work on the data:
Organize C# Using Statements
The C# editor has added some great intellisense improvements as well. Some of the biggest obviously include language intellisense and refactoring support for the new language features (Lambdas, Extension Methods, Query Syntax, Anonymous Types, etc). Just like in our VB example above, C# supports type inference and intellisense completion of anonymous types:
One of the small, but nice, new features I recently noticed in VS 2008 is support for better organizing using statements in C#. You can now select a list of using statements, right-click, and then pull up the "Organize Usings" sub-menu:
You can use this to alphabetically sort your namespaces (one of my pet peeves), and optionally use the 'Remove Unused Usings" command to remove un-necessary namespace declarations from the file:
When you use this command the editor will analyze what types you are using in your code file, and automatically remove those namespaces that are declared but not needed to support them. A small but handy little feature.
Summary
The above list of editor improvements is by no means exhaustive, but rather just a few small improvements I've played with in the last week. Post others you notice in the comments section of this post, and I'll try and do an update with more in the future.
Thanks,
Scott