2

I have a custom JavaScript file and it's getting large. The problem is, though the whole JavaScript is well-written and there is no syntactical error (even colons are there), Visual Studio 2010 can't format the document. I extracted each part separately to a separate file, and there, formatting Ctrl + K + D or Ctrl + E, D works just fine. But when they come together formatting stops working. I saw other posts, and they had no such problem. So I posted my question here.I know that Visual Studio is still at it's infancy for JavaScript support. But do you have the same problem? Is there a way to make JavaScript experience better in VS2010?

Saeed Neamati
  • 35,341
  • 41
  • 136
  • 188
  • Something that may or may not help... recent blog post from Scott Hansdelman: [Announcing the Web Standards Update - HTML5 Support for the Visual Studio 2010 Editor](http://feedproxy.google.com/~r/ScottHanselman/~3/LMnWyIIg8CM/AnnouncingTheWebStandardsUpdateHTML5SupportForTheVisualStudio2010Editor.aspx), had some javascript improvements rolled in. – slugster Jun 29 '11 at 07:22
  • Yeah, I know about HTML5 Support for VS2010, and I'm actually using it. I tried that too, but VS seems to be week at handling large JavaScript files. But for HTML5, I also suggest [this](http://www.thoughtresults.com/downloads) snippet. Problemo still exist. – Saeed Neamati Jun 29 '11 at 07:29

2 Answers2

2

I use Ctrl+E, F. Give it a try.

asma
  • 2,795
  • 13
  • 60
  • 87
  • Actually, the shortcut doesn't matter, as it's just an option triggering the format procedure. Mine is `Ctrl + K, Ctrl + D` or `Ctrl + E, D`. But I also tried that and it didn't work. Thank you anyway for responding :) – Saeed Neamati Jun 29 '11 at 07:22
  • you're welcome. It must be the lacking functionality of VS10. Unfortunately you will have to format manually :) – asma Jun 29 '11 at 07:24
  • 1
    This worked for me in VS2013 when the CTRL+K shortcuts and right click menu did not. –  Dec 31 '13 at 16:58
2

There are quite a few things you can do to improve your javascript experience:

1 - Install the WebStandards update: http://www.hanselman.com/blog/AnnouncingTheWebStandardsUpdateHTML5SupportForTheVisualStudio2010Editor.aspx

2 - Perhaps one or more of the Javascripts extensions will help you. Go to the Tools Menu, select Extensions, and then search for Javascript. (#1 is actually the first install that comes up).

But there are a number of other extensions that claim to improve javascript parsing. There's also a JSLint as well.

I hope these help!

  • Daniel
Daniel Corbett
  • 255
  • 2
  • 10
  • This update was really awesome and something I was looking for. To tell the truth, I'm gonna use it a lot. Thank you for mentioning it. However, the damn JavaScript problem still exists. I think VS IDE is not really professional for working with JavaScript. Seems that we have to wait till next release. – Saeed Neamati Jun 29 '11 at 07:44
  • Did you try the other extensions... [this one:Javascript parser] (http://visualstudiogallery.msdn.microsoft.com/288a2b0f-1357-47b4-8215-1134c36bdf30?SRC=VSIDE) claims to help when editing large javascript files. – Daniel Corbett Jun 29 '11 at 10:29