42

Is it possible to create code regions in JS files in Visual Studio 2010?

This method works in 2005, but I can't get working in 2010.

Community
  • 1
  • 1
Mr. Flibble
  • 26,564
  • 23
  • 69
  • 100
  • Try it, if the compiler throws you an error, then it obviously won't work. ;) – Zack May 27 '10 at 17:04
  • I have. I actually got stuck at adding a keyboard shortcut to the macro. I've never used VS macros before so am probably doing something silly. The macro doesn't seem to appear in the list when I try and assign a keyboard shortcut to it. Have you any idea why that would happen? – Mr. Flibble May 27 '10 at 17:19
  • Oh, Type "macros" in the search box. It'll auto-show all macros. Here's the full tutorial on this: http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html – Zack May 27 '10 at 17:44
  • Cheers Zack. I followed that tutorial. No idea why the macro doesn't show up. – Mr. Flibble May 27 '10 at 18:22
  • Is it still not showing up? :\ – Zack May 27 '10 at 19:06

8 Answers8

37

Here is a very cool VS2010 extension for Javascript and CSS outlining http://jsoutlining.codeplex.com/

Alex Yeung
  • 2,495
  • 7
  • 31
  • 48
33

Microsoft now has an extension for VS2010 that provides this functionality:

JScript Editor Extensions

BrianFinkel
  • 2,687
  • 3
  • 26
  • 28
1

Advanced JavaScript Outlining for Visual Studio 11 is now available for VS2012 through the Extension Manger, or at the URL

http://visualstudiogallery.msdn.microsoft.com/4be701d8-af03-40a4-8cdc-d2add5cde46c?SRC=VSIDE

Eric J.
  • 147,927
  • 63
  • 340
  • 553
1

The JSEnhancements plugin for Visual Studio addresses this nicely.

Joel Harris
  • 1,966
  • 3
  • 20
  • 32
0

Another great Visual Studio 2012-Extension is Web Essentials 2012. There are a bunch of cool tools for even TypeScript, LESS and CoffeeScript.

http://vswebessentials.com/

kwrl
  • 653
  • 8
  • 12
0

Even though VS extensions installed, I had a unique problem of some of the script blocks not outlining properly, later found that its because of the @Url.Content tag used in the script, simply replaced it with simple string url, the outlining worked....thought of sharing if it helps someone

rcp
  • 301
  • 4
  • 10
0

In VS 2015 you can just create a block around your "region" like this

{ //My little region
  function misc()...
  var x = '';
  //etc...
  ...
}

Then just collapse that block. Probably on all older versions of Visual Studio as well.

Wolf5
  • 16,600
  • 12
  • 59
  • 58
0

There's an interesting post here : http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html on how to do this using Macros in Visual Studio.

Hope that help.

Update I just realised that someone has already referenced this link in the comments.

Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162