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

55 Comments

  • Anxiously waiting for my download to finish. It's nice to see the subtle details being put into the Beta 2 release, they are handy additions. Thank you Scott for your constant work and dedication to the developer community.

  • Good information, I too always found the drop down Intellisense box annoying at times when trying to view the code beneath it. Thanks for the write up!

  • Hi Scott,
    It would like to know if it has difference in Intellisense of vb.net and c#?
    thanks!

  • Wow - that using sorting and remove stuff has just automated something I do everytime I create anything in VS, especially when using things like WinForms that has a whole load of using directives and only 2 of them are actually being used...same goes for ASP.NET web forms as well.
    Great stuff - the transparent intellisense is really great too.
    Also Scott with several files open in VS hold down Ctrl + Tab and you can use the new file switcher which is pretty cool.

  • I like the sorting of Using statements. its one of my pet peeves as well. Thanks for sharing.

  • I have had a day to play around with VS 2008 now and so far it has been a very positive experience. The new javascript intellisense and transparent intellisense features are SWEET!

  • Thanks mentioning these new features Scott. I would have never figured out the intellisnese transparency feature.

    Thanks,
    Amrinder

  • Scott,
    Is it true that there's no support for Code Snippets in Javascript? I was pretty disappointed when I heard that, especially since building classes for ASP.NET AJAX involves a lot of boilerplate code.

  • Hi Scott;
    OT subject! Scott, the LINQ syntax seems to be very natural and clean way of writing code, however, what throws me off, is the Lambada syntax. Every time I begin to look at a LINQ statement that is a bit complex, I see the Lambada expression thrown into the linq query.

    My First question, why do we have to deal with Lamabda?
    Secondly, can you define how and where Lambada should be used?
    and last, but not least, what is this new operator "=>"?

    Thanks!

  • Hi Kevin,

    >>>>>>> Is it true that there's no support for Code Snippets in Javascript? I was pretty disappointed when I heard that, especially since building classes for ASP.NET AJAX involves a lot of boilerplate code.

    Unfortunately the team ran out of time to get the code-snippet work in this release for JavaScript. :-( There are, however, item templates for ASP.NET AJAX types that can be used to help automatically create the appropriate boiler-plate code for common things.

    Hope this helps,

    Scott

  • Hi Ian,

    >>>>>>> In an early VS "Orcas" spec document, new toolstrip colors, etc. were show, including the new blue tab border. The only thing I see now, in beta 2, is the blue tab border. Are the toolbars going to be changed? I really liked the new look as outlined in the spec.

    That is good question. To be honest with you, I don't actually remember what they were in the beginning of the project, so am not 100% sure how they have evolved.

    We have a centralized user experience (UX) team that actually handles designing the overall color scheme of VS as well as all of the icons and graphics used within it. They then iterate and check-in the final look and feel of the product shortly after Beta2 (when we declare "visual freeze" on the product). I'm not sure whether there are more changes still to be made, or whether the current color palatte is the final one.

    Hope this helps,

    Scott

  • Hi Ben,

    >>>>>>> OT subject! Scott, the LINQ syntax seems to be very natural and clean way of writing code, however, what throws me off, is the Lambada syntax. Every time I begin to look at a LINQ statement that is a bit complex, I see the Lambada expression thrown into the linq query. My First question, why do we have to deal with Lamabda? Secondly, can you define how and where Lambada should be used? and last, but not least, what is this new operator "=>"?

    Lambdas are a pretty powerful concept that I think once you understand you'll really like using - although initially the syntax might look a little odd. The good news is that if you don't like Lambdas, you don't need to use them. You can use LINQ query syntax for everything and avoid the Lambdas (although they are a useful short-hand).

    At a high-level, you should think of Lambdas as a way to write concise inline methods. The expression to the right of the => character is the method body, and the variables to the left of the => character are the parameters being passed into it.

    params => expression

    I have a detailed blog post: http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx that I recommend reading to learn more about how they work and how to use them.

    Hope this helps,

    Scott

  • Simply amazing...fantastic work, and kudos to the development teams behind VS 2008!

  • Regarding Lambdas (the question from Ben above), when I was first learning LINQ at the PDC in 05, and looking at Lambdas I did wonder if for the common scenario (of 1 parameter) you could have simplified the language syntax and used an implicit variable name (maybe even overload the use of var for this purpose such as:
    .Where(item => item.FirstName == "Smith")
    to:
    .Where(var.FirstName == "Smith")

    That might have been easier for beginners to read for the 90% case, and is similar to powershell where you can do $_.FirstName syntax (ie 'var' is the same as '$_' in my example).

    But in the end I trust the language designers :-)

    Lambdas will take people a few hours to grasp, but it is pretty easy once grasped.

    David

  • A bit dissapointing really! I would have like to see a *real* search on the intellisense popup, eg. typing "gbo" will come up with msgbox(). Sometimes it's really hard to remember the *start* of the function or API, and that's what slows me down the most when programming :(

  • Hi Scott,

    Nested MasterPage didn't show in design view correctly in Web Application project. What's wrong?

  • I used to develop on Eclipse in another life as well. Great to see the Cleanup Imports equivalent arriving in VS.

    My team actually gets scared when I look at code-behind files and see the default import list in their file, because they know pain is coming ;)

    I'm still waiting for B2 to finish downloading, be interested to see if Resharper/Eclipse level refactoring performance is in 2008

  • Hi Scott,
    Does VB support Lambda Expression in beta2?

  • Scott,

    First, I must say, I love VS 2008 and have had a great experience with Beta 1. My only complaint would be VB intellisense; I really don't think the new filtering approach is an improvement.

    Imagine a scenario where you have two properties on an object, .Name and .Email, and you are assigning them both. In 2005 a quick Ctrl+C Ctrl+V after you'd typed the first line and then hit backspace to see all the properties. If the object only has a few properties then Email will only be a few lines from Name and reachable with a few up-arrow key-presses.

    With the new filtering I have to delete the whole property name before Email will appear in the list. This is also really annoying if you select the wrong property and want to back-up.

    Is there anyway to turn off this feature, or at least expand the list back out again?

    Thanks,

    Darren

  • Hi Scott,
    I have not started using the Beta 2 because I'm still downloading it, but please in C# intellisense features, does c# editor contains the parenthesis auto-completion that exists in NetBean IDE 5.5 for Java? such that when you type open parenthesis for a method you get the other closing parenthesis typed by the editor so also open and close quotes. If it is not in C# yet, it will be nice feature when C# team adds it and this will increase developers' productivity.
    Many thanks for your great tips.
    Regards,
    Ibrahim

  • I like the new Ctrl+Tab interface in Orcas...nice preview!

    Transparent thing is a top 10 new feature in my eyes!!

  • Hi NGoc,

    >>>>>> Nested MasterPage didn't show in design view correctly in Web Application project. What's wrong?

    I just tested nested master pages in web application projects, and they work fine for me. I think what you mean is that there isn't a nested master page option in the "Add New Item" dialog with web application projects. This unfortunately is missing in Beta2 - instead you'll want to create a new regular master page and then manually update its "masterpagefile" attribute to point to the parent once it is created. Nested master pages will then work fine in the designer.

    Hope this helps,

    Scott

  • Hi Darren,

    >>>>>>> Is there anyway to turn off this (auto-filter) feature, or at least expand the list back out again?

    I just sent mail to the VB team to see what configuration options there are with it. I'll let you know what I hear back.

    Thanks,

    Scott

  • Hi Majid,

    >>>>> Does VB support Lambda Expression in beta2?

    Yes - VB in Beta2 now fully supports Lambda Expressions. Here is an example of the VB syntax for the scenario above:

    Dim products = From p In db.Products _
    Where p.Category.CategoryName = "Beverages" _
    Select Name = p.ProductName, NumOrders = p.OrderDetails.Count, Revenue = p.OrderDetails.Sum(Function(o) o.UnitPrice * o.Quantity)

    The Function(o) syntax in the expression above is an example of the Lambda.

    Hope this helps,

    Scott

  • Just an FYI, you don't need to select the using statements to sort / remove them. I haven't tested if selecting them allows you to specify a set of using statements to act upon. Great feature though!

  • I was thinking just a few days ago how much better intelisense would be if the member list was filtered. But I tend to agree with Tyson, the member list would be much better if it did a contains ('%gbo%') filter instead of a begins with ('gbo%') filter. If you also added this to C# then I would rate it in my top three for Text editor enhancements.

  • Really good this post, just let me know if we will got in VB a same command like Remove Unused Imports, just like Remove Unused Using of his brother C#???

  • Hi Scott,

    Great work. I like the using things. Its great to be removed when not used in the page.

    One request. Can we have a small project download were we can see a project using LINQ to sql in the data access layer. I mean I have not yet seen an example were I know what will be the type of the function which uses the LINQ. I mean If I am passing only 3 fields from a table of 10 fields, What type will I be passing back.

    Thanks

  • I could not agree more with Des and other before him. I was VERY disappointed to see that this intellisence filtering doesn't work for C#. I can live with it, since I have ReSharper (at least at work) but it might be the best User Experience Enhancement in my opinion. Especially if you could write mex and it would behave like following regular expression \w*m\w*e\w*x\w* that is "give me anything that has in its name letters m and e and x in this order", for example MEssageboX. Is it doable for RTM?

  • Ha, thanks scott another good thing as usual, and i liked the things about VB.Net tooltips, i always knew VB.Net is the better language to work with :P

  • Hi Scott,

    I also agree about the search feature of intellisense. It should support LIKE searchs (%abc%). Since intellisense window is already alphabetically sorted, it would not be a very big step forward without a LIKE search feature.

  • I'm so waiting for Javascript intellisense. I currently working on Ajax client libraries and its a pain and you can't figure out the variables, namespaces etc.

    When is VS 2008 due ?

  • After coding in C# for a year and then doing a project in VB I notice how the intellisense for VB is very different than it is for C#. I know, different languages, but still... In C# a ctrl-space is all you ever seem to need, but in VB I always seem to end up with unwanted spaces, new lines, tabs etc. You have to be very specific to correctly auto-complete.

    It's very confusing, could it not be made more the same? VB is 'teh suck' if you ask me, but the intellisense issue has made it even more aggravating to code this project.

  • Someone mentioned the ctrl-tab file switcher, it has black text on blue background (Windows XP with theming enabled) which is very hard to read. Should be fixed imho.

  • Believe me! I'm not seeing thing! I really saw it.

    When I just installed Beta2 and opened my ASP.Net pages, the code coloring scheme was different. Some very nice pastel colors instead of regular bright yellow and blue "mosaic" all over the page as usual. But then it was gone.

    Is there really such a scheme, or I should go and check my eyes?

  • Is it jus me, but cleaning up using statement is mainly cosmetics.
    But cleaning up your references would be much nicer, or is the compiler clever enough to sort out references not used ?

  • >>But cleaning up your references would be much nicer, or is the compiler clever enough to sort out references not used ?
    Look in Project Properties/References

  • Great stuff, VS keeps getting better and better!

    A "feature" (or feature-set) request for the next version: could these formatting / code cleanup options be made part of either the project, or part of a tool that applies to all files in a project? It's a pain to sync up each developer's code formatting settings, and if you don't, source control ends up full of minor, automatic, reformats. Alternatively, perhaps a commit filter could be applied so that code is reformatted and tidied on commit?

  • Did you improve the FTP stuff? Sure seems clunky and behind other available software. . .

  • Hi Darren,

    >>>>>> My only complaint would be VB intellisense; I really don't think the new filtering approach is an improvement.
    Imagine a scenario where you have two properties on an object, .Name and .Email, and you are assigning them both. In 2005 a quick Ctrl+C Ctrl+V after you'd typed the first line and then hit backspace to see all the properties. If the object only has a few properties then Email will only be a few lines from Name and reachable with a few up-arrow key-presses.
    With the new filtering I have to delete the whole property name before Email will appear in the list. This is also really annoying if you select the wrong property and want to back-up. Is there anyway to turn off this feature, or at least expand the list back out again?

    I just heard back from the VB team, and they've heard this request as well. For the final RTM version, when a user backspaces in intellisense, the completion list will include all items in the list unfiltered and filtering will resume when the user starts typing forward again. I think this should address your concern over the current behavior.

    Hope this helps,

    Scott

  • Please add the ability to highlight a group of private variables and create public properties for them.

    Right now, it's one at a time, very time consuming.

  • I type List< and my intellisense doesn't show System.Collection.Generics to add a using - instead it shows mobile controls???

  • Hi Steve,

    >>>>>> I type List< and my intellisense doesn't show System.Collection.Generics to add a using - instead it shows mobile controls???

    I suspect you have the System.Web.UI.MobileControls namespace imported - which is why you are seeing that behavior (that namesspace has a List mobile control). If you qualify it you'll get the right result.

    Hope this helps,

    Scott

  • Hi Ameer,

    VB definitely supports colorization (just like C#).

    Hope this helps,

    Scott

  • Hi Scott,

    I am currently making a painful transition to VB.NET from C#. I have grown used to the coloring that C# uses for user created types and classes in the code. But this coloring doesn't work in VB.NET. I tried changing the color for the "User Type" and others in the "Tools->Options->Environment->Font and Colors" section of Visual Studio 2005. But still my VB.NET code was not rendering the way my C# code gets rendered. The settings seem to work for C# and not VB.NET. Can the same coloring scheme be done in VB.NET also or did Microsoft forget to implement the coloring scheme for VB.NET?
    Does VB support colorization in VB.NET 2008?

    Thanks

  • Scott,

    Thanks for all your great articles and blogs! Can you just tell respond with a quick yes/no if VS2005 supports Dual/Quad core during the ASP.Net build process (perhaps parallel building of libraries which reside in a solution or parallel directory validation of code in the website)? If not, do you know if Orcas will? I've been searching for the answer for days on the web to no avail.

    Many Thanks,
    Jim

  • Hi Ameer,

    >>>>>> But still my VB.NET code was not rendering the way my C# code gets rendered. The settings seem to work for C# and not VB.NET. Can the same coloring scheme be done in VB.NET also or did Microsoft forget to implement the coloring scheme for VB.NET?

    The keywords are different in VB and C#, which might be the reason the colors look different. Are you sure this isn't the case? VB definitely does colorize.

    Thanks,

    Scott

  • Hi J. Bishop,

    >>>>>>> Thanks for all your great articles and blogs! Can you just tell respond with a quick yes/no if VS2005 supports Dual/Quad core during the ASP.Net build process (perhaps parallel building of libraries which reside in a solution or parallel directory validation of code in the website)? If not, do you know if Orcas will? I've been searching for the answer for days on the web to no avail.

    For command-line builds I believe the compilers have been updated to support parralel build execution across multiple cores on a machine. Within the IDE itself I'm not sure how much additional parrallism there is - although I suspect you'd definitely see some benefits from at least 2 cores.

    Hope this helps,

    Scott

  • >>>>>>> Are you sure this isn't the case?

    Yes i sure!, Please test it tis case:"Tools->Options->Environment->Font and Colors=> User Types.

  • It is very difficult to miss out your blog. Again one more nice and advance information.
    Big thanks for your wonderful post.

    Mahesh

  • Hi m4h4r4,

    >>>>>> Honestly, I'm a little bit tired of asking these kind of questions, but why don't you guys make the following features to be consistent over (at least) C# and VB.NET. Could you tell me Scott what is the ratio behind those decisions? .... (Yes, of course you would say: resources; but honestly, that doesn't help). For me, the ratio is that because simply both (at least C# and VB.NET) users would need them.

    Unfortunately it does usually come down to resources - we only have a finate set on each team, and the teams often end up having to make trade-offs based on priorities. In some cases VB decided to invest more heavily in new language features (for example: the new XML literal support which is pretty sweet), over having 100% parity with all of the editor features. The C# team did most of the LINQ library work, and ended up having to devote resources to that which couldn't be used to have parity with all of the VB editor features.

    I think you'll find that the majority of editor features are common to both, and that in future releases of VS each team will complete the missing gaps.

    Hope this helps provide some context,

    Scott

  • Hi Scott,

    thanks for the explanation. Yes, it does provide another deeper context to better understand this kind of issues. If you said that "in future releases of VS each team would complete the missing gaps", I gues that is the only way it would be then... :(

    I do wish that you guys could somehow handle this consistency issues better in the future.

    Hopefully, MS could always build very great products in the future.

    Thanks!

  • These are great enhancements! I was just curious if there's by chance keyboard accessibility to the remove and sort usings context menu actions.

    I find myself using this a lot and a quick keyboard shortcut would be nice. I just haven't dug around for it in the options to find it.

    Thanks

  • Hi Dean,

    >>>>>> These are great enhancements! I was just curious if there's by chance keyboard accessibility to the remove and sort usings context menu actions.

    I'm pretty sure that you can configure a keyboard option to avoid having to use the context menu - although I haven't figured out what it is just yet. :-)

    Thanks,

    Scott

  • I have a problem in vs2005 form designer. Here is my situation
    I have an abstract FormBase class (Inherits System.Windows.Forms.Form)
    If I want a Form1 inherits from FormBase I can't use the Form Designer. It raise an error "The designer must create an instance of type '.......' but it cannot because the type is declared as abstract"

    Did you guys fix this in VS 2008?

Comments have been disabled for this content.