Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I don't think it is possible right now in VS2010/VS2008 but I'm sure someone must have done or can come up with some workaround using the extensibility of VS2010/VS2008.

Ability to collapse javascript function/comment blocks within script tag in an aspx file editor and in javascript(*.js) file editor the same way we can do in any other editor (c#,vb,xml) will be very useful to many out here and on stackoverflow.com.

I was just thinking that if it is possible by creating #region blocks as we do in c# editor.

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Ah! I got to figure out. But I couldn't auto outline it.

This solution works in VS2010. I've not checked with VS2008.

  1. Select whole of the Javascript block that you want to collapse in the aspx editor.
  2. Right click on it and select Collapse Tag or Press Ctrl + M, Ctrl + T

Anyways, now I cannot figure out the shortcut key to expand this particular block which was collapsed in the above mentioned way because Ctrl + M, Ctrl + M is not toggling this block.

Many thanks to @Force Flow for the inspiration.

share|improve this answer
    
Ctrl+M, Ctrl+M works for me. Toggles expansion and collapse. –  jamiebarrow Feb 25 '11 at 6:50
    
Lucky guy!!!!!! –  iSid Feb 25 '11 at 13:12
    
This did not work for me with visual studio 2010 i have posted a new answer where i point to a plugin i found. VisualStudio 2010 JavaScript & CSS Outlining –  Mortalus Sep 29 '12 at 14:57

does not work on vs2008 :(

I found this. It works perfect on vs2008, I don't know if it does in vs2010. http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html

is a macro that collapses the //#region and //#endregion in a javascript file.

Hope this hepls :)

share|improve this answer
    
Thanks a lot. Something good in the way. But still I've to write //#region and //#endregion all the way in whole of my current code. It would have been great if it could identify the function boundaries on it's own. I think same macro can be improvised. –  iSid Oct 8 '10 at 5:46
    
Yes, great idea! I think it definitely could be done. I don't have much time to improve the code. Anyway I will try to make it over the weekend. If I get something useful I will let you know in this post :) –  barclow Oct 8 '10 at 16:18

Hey i found this plugin that woks great.

VisualStudio 2010 JavaScript & CSS Outlining

share|improve this answer

Give this a try: highlight the code you want to collapse, then double click somewhere in the line numbering area.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.