Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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!!!!!! – IsmailS 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

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .