Welcome to MSDN Blogs Sign in | Join | Help

Visual Web Developer Team Blog

Your official information source from the Visual Web Developer team.

News

  • These postings are provided "AS IS" with no warranties, and confer no rights. Use of included code samples are subject to the terms specified Terms of Use
Introducing JScript Formatting in VS 2008 SP1

treeview Colorization, validation, IntelliSense, and formatting comprise the core of any modern editor.  With VS 2008 SP1, we are completing the core JScript editor by introducing code formatting.  Additionally, we have promoted JScript to a dedicated node in “Tools Options” providing a clean separation from the HTML “Tools Options”.  We realize many folks have been waiting for this feature and we’re excited to be able to finally provide it.

We’re using “beta” period to fine tune the feature for final release.  Thus, we would love to hear any feedback you have.  There are two areas in particular I’d like to highlight:

  • Correctness – It goes without saying that code integrity is of highest priority.  We’ve done extensive testing to make sure nothing beyond the visual appearance of the code is modified by formatting.  If in any case formatting has not preserved the semantics of your code, please let us know.
  • Preferences – The rest of “correctness” is a subjective matter.  To that end, we’re trying to strike the right balance of formatting options—freedom to control how your code looks while not being overwhelmed by options.  If your particular formatting style can’t be achieved with the current set of options, we’d like to know.

At this point please feel free to just download the Service Pack and dive into the feature.  If you're interested in the details of JScript Formatting and related options, please feel free to continue reading.

Invoking Formatting

There are a couple of different methods available to invoke formatting.  They can be invoked automatically while typing when any subset of the ‘Automatic Formatting’ options are checked.  They can also be invoked via the ‘Edit / Format Document’ and ‘Edit / Format Selection’ menu items. Once invoked, all settings in the Formatting tab will be applied.

The JScript Formatting settings are available within four tabs under the new Tools / Options / Text Editor / JScript node. These four tabs are: General, Tabs, Formatting, and Miscellaneous, as seen below.

General and Tabs

The first two tabs are standard across all editors (including JScript). The settings found in these tabs are what we describe as Editor Level settings. This means that when JScript exists on a mark-up page, and the setting within the JScript node conflict with those on the equivalent HTML node; the settings on the HTML node will prevail. Although, most setting behave the same across all editors, there are a few items which need to be called out:

  • Statement Completion
    • Auto list members: This turns on/off our auto-triggering mechanism. This does NOT turn Statement Completion off (aka: you can still use Ctrl+J and Ctrl+Space).
    • Hide advanced members: Permanently disabled. Not supported.
  • Display
    • Navigation bar: This option is always disabled since we do not support it in JScript.
  • Indenting
    • Smart: Permanently disabled in this release of the product. We were unable to include this feature for this release of the product, but hope to include it in a future release.

Formatting

The third tab is custom made for JScript and contains the meat of the JScript Formatting feature. We will go into more detail as to what the settings mean and the affect they will have on JScript code.

formatting

Automatic formatting: This section refers to WHEN formatting will occur as the user is typing in and manipulating code in ‘real time’. Basically, formatting is being performed as the user is constructing the code.

  • Format completed line on enter (default ON): Once {ENTER} is pressed, the line will be formatted according to the options set
  • Format completed statement on ; (default ON): Once ; is pressed, the line will be formatted according to the options set
  • Format completed block on } (default ON): Once } pressed, the block will be formatted according to the options set
  • Format on paste (default ON): Once code is pasted into the editor, it will be formatted according to the options set
    Note: Dragging and dropping within the editor should not invoke formatting.

New lines: This section refers to where braces will be inserted with regards to functions and control blocks

  • Place open brace on new line for functions
    Off: function foo() {  // default
         }
    On:  function foo()
         {
         }
  • Place open brace on new line for control blocks
    Off: if (a==b) {  // default
             var c = 3;
         }
    On:  if (a==b)
         {
             var c= 3;
         }

Spacing: This section refers to how spacing will be inserted (or taken out) when formatting is invoked via automatic formatting (as described above) or through an intentional invocation via ‘Format Document’ or ‘Format Selection’.

  • Insert space after comma delimiter
    Off: var a,b;
    On:  var a, b;  // default
  • Insert space after semicolon in “for” statement
    Off: for(i=0;i<10;i++)
    On:  for(i=0; i<0; i++)  // default
  • Insert space before and after binary operators
    Off: a+b;
    On:  a + b;  // default
  • Insert space after keywords in control flow statements
    Off: for(i=0;i<10;i++)
    On:  for (i=0;i<10;i++)  // default

Miscellaneous

The final tab is specific for JScript and contains validation rules as well as statement completion options. The Validation section was removed from the Tools / Options / Text Editor / HMTL / Validation tab and given its own space under the JScript node; while the Statement completion section was taken from the Tools / Options / Text Editor / HTML / Miscellaneous tab.

misc

Validation

  • Show syntax errors (default ON). Now you are able to enable and disable JScript validation separate from HTML validation.
  • Show errors as warnings (default ON). When this is checked, the ‘severity’ of the error / warning is demoted. For instance, if 1 error and 1 warning was displayed in the error list while this was unchecked; then 1 warning and 1 message would be displayed if this was subsequently turned on. This is the same feature as mentioned previously and it is on by default so that your client-side errors don't interfere with the discovery of your compilation errors.

Statement completion

  • Only use TAB or ENTER to commit (default OFF).  We received feedback that JScript IntelliSense was at times too aggressive.  For example, a new variable "x" will often accidentally complete as "XMLHTTPRequest" when you press "=".  Limiting the completion triggers to TAB and ENTER as been found to mitigate this issue.

Caveats

  1. Certain options will not make sense if on a page with both script and HTML. For example, you can't (shouldn't) have line numbers on for certain lines and off for others. Thus if the settings conflict, the parent editor settings will win. The parent editor settings should always be the HTML editor. In the event that you have a JScript File, the settings in the JScript tab will be the settings which are used regardless of the corresponding settings chosen in the HTML editor’s section.
  2. When formatting is invoked, all settings in the Formatting tab will be applied. This means that spaces can also be removed and braces moved depending on the state (checked vs. unchecked) of the formatting option. Effectively, this means that there isn’t the concept of ‘no formatting’.
  3. Formatting (both automatic and forced via the menus) only occurs when there are no syntax errors. So, if there is a function that does not have its closing bracket (}), then formatting will not occur as this is considered a syntax error until the function is bracketed. To this end, we are considering the implementation (sometime in the future) of an additional option to allow the user to have closing brackets auto inserted.

We hope this gives you a complete picture of the various customizations possible and serves to make your JScript editing experience better!  Once again, we look forward to any feedback you have to provide.

Nichole Baker and Jeff King
SDET and Program Manager
Web Tools

Posted: Monday, May 12, 2008 8:59 AM by WebDevTools

Comments

ScottGu's Blog said:

Earlier today we shipped a public beta of our upcoming .NET 3.5 SP1 and VS 2008 SP1 releases.&#160; These

# May 12, 2008 12:51 PM

BusinessRx Reading List said:

Earlier today we shipped a public beta of our upcoming .NET 3.5 SP1 and VS 2008 SP1 releases.&#160; These

# May 12, 2008 1:01 PM

Mirrored Blogs said:

Earlier today we shipped a public beta of our upcoming .NET 3.5 SP1 and VS 2008 SP1 releases.&#160; These

# May 12, 2008 1:30 PM

Blog said:

{Copy paste uiteraard....} Earlier today we shipped a public beta of our upcoming .NET 3.5 SP1 and VS

# May 12, 2008 5:18 PM

beqiraj.net said:

Visual Studio 2008 Service Pack 1 Beta is now available!

# May 12, 2008 6:48 PM

beqiraj.net said:

Visual Studio 2008 Express Edition Service Pack 1 Beta is now available!

# May 12, 2008 6:51 PM

beqiraj.net said:

Visual Studio 2008 Express Edition Service Pack 1 Beta is now available!

# May 12, 2008 6:51 PM

beqiraj.net said:

.NET Framework 3.5 Service Pack 1 Beta is now available!

# May 12, 2008 6:54 PM

Guru Stop <!-- Mohamed Meligy --> said:

Microsoft .NET framework 3.5 Service Pack 1 and Visual Studio 2008 Service Pack 1 now have public BETAs

# May 12, 2008 7:03 PM

gOODiDEA.NET said:

.NET Visual Studio 2008 SP1 Beta VS2008 SP1 and .NET FX Beta Performance Improvements Introducing JScript

# May 12, 2008 8:30 PM

gOODiDEA said:

.NETVisualStudio2008SP1BetaVS2008SP1and.NETFXBetaPerformanceImprovementsIntroducing...

# May 12, 2008 8:30 PM

Visual Studio Hacks said:

My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Carlos Quintero wrote an article explaining how to open the web browser and navigate to a page from a Visual Studio add-in or macro

# May 13, 2008 9:12 AM

Scott Guthrie's Blog in Dutch said:

Eerder deze week brachten we een publieke betaversie uit van de komende .NET 3.5 SP1 en VS 2008 SP1.

# May 15, 2008 4:47 AM

Scott Guthrie's Blog in Dutch said:

Eerder deze week brachten we een publieke betaversie uit van de komende .NET 3.5 SP1 en VS 2008 SP1.

# May 15, 2008 5:34 AM

Joycode@Ab110.com said:

【原文地址】 Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta 【原文发表日期】 Monday, May 12, 2008 9

# May 16, 2008 3:50 AM

Cyril DURAND said:

When will you provide a real JavaScript editor ? With brace matching, function collapsing, XML comment support, etc...

C# do it, it won't be so difficult to do it for JavaScript !

I post a suggestion here : https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=342341

# May 17, 2008 11:27 AM

Your Websites, Our Passion! said:

Visual Studio 2008 SP1 Beta is now available! You can download it here (though before you do, read the

# May 20, 2008 12:55 PM

Shimon said:

How do i enable extjs Intelisense?

# May 29, 2008 9:13 AM

WebDevTools said:

@Shimon: as long as your page references the extjs library, IntelliSense should just work.  In SP1, there's no work around needed.  Thanks!

# May 29, 2008 12:25 PM

Daniel Steigerwald said:

Folding!!! We need code folding...

# May 29, 2008 8:32 PM

Stuart said:

Has anyone managed to get the SP1 beta extjs intellisense to work? I'm referencing ext2.1 on my page but the intellisense refuses to work!?!?!

# June 11, 2008 9:14 PM

WebDevTools said:

@Stuart: What error are you seeing?

# June 11, 2008 9:23 PM

Stuart said:

@WebDevTools

Thank you for responding..

I started a new web project and referenced the base and core js files from the extjs 2.1 release. I expected the intellisense to work from that. Should it? No errors have been reported..

# June 13, 2008 12:51 AM

Zachariah Young said:

VS2008 and .Net 3.5 SP1 Beta - Install complete

# June 29, 2008 8:08 AM

Keith Beller said:

JScript Formatting in VS 2008 SP1 Not displaying in VS 2008/XP Pro install.

Add Code Folding for Javascript and CSS.

# July 2, 2008 12:55 PM

Lee Stimberg said:

Urgent!!!

please support javascript code folding in upcoming release of VS2008 service pack 1.

Some file in our project runs into thousands line of codes and you know how painful it is to travel around the code :horror:

# July 21, 2008 7:15 AM

WebDevTools said:

@Lee Stimberg: Unfortunately, it will not be SP1, but we're working on better ways to navigate large files.  Thanks for the feedback!

# July 21, 2008 12:19 PM

Adam said:

I could not get any of the code formatting or intellisense working for my .asp files. They are written in JScipt/Javascript, but nothing seems to work. Do i have to map them or something??

I have 2008 web dev with sp1 installed.

Cheers

# July 23, 2008 3:32 AM

EdSF said:

Thank you!

Will wait for production release of VS 08 SP1 for this much needed feature - re: don't really like the notion of installing a beta on my most used development tool...and the gyrations likely needed when the production version does come out (uninstall beta/install production).

# August 3, 2008 3:01 PM

Tips & Tricks for ASP.NET, IIS, and Visual Web Developer said:

&#160; Anh Phan SDET, Visual Web Developer With Visual Studio 2008 RTM, JScript validation setting is

# June 15, 2009 2:54 PM

Web Developer Tips said:

With Visual Studio 2008 RTM, JScript validation setting is an option on the HTML validation page on the

# June 15, 2009 6:35 PM
New Comments to this post are disabled
Page view tracker