Hide comments in Notepad++

14,643

Solution 1

I came across the same problem some time ago. One thing you can do is put your comment lines between braces like:

{  //Hidden comments

//Word.Document doc = wordApp.Documents.Open(ref outputFile, ref nullobj, ref nullobj,     
//                                    ref nullobj, ref nullobj, ref nullobj,           
//                                    ref nullobj, ref nullobj, ref nullobj,            
//                                    ref nullobj, ref nullobj, ref nullobj,            
//                                    ref nullobj, ref nullobj, ref nullobj,ref nullobj);
}

So you can collapse it and see it this way:

{  //Hidden comments

Solution 2

In Notepad++, choose HTML from Language menu. And if you have comments like this:

<!-- here are some html comments
  sdfasdfadsf
  asdfasdf
-->

You will be able to fold them just fine. you can use Fold All to collapse the whole html content, and then start unfolding from there (to only parts that you want to see).

Solution 3

Workaround

Use alt+h to hide lines.

Fix

The following describes the setup of code-folding/comment-folding for in-line and multi-line comments on an existing language file using NPP.

**WARNING: Clicking the X at the top-right will close the document, so click Undock in step 4, to close the UDF dialog, not the X. You can recover a closed document in the File drop-down menu.

**WARNING: You may need to restart NPP to see the UDF in the Language drop-down menu; so, don't get flustered.

**WARNING: In step 4: I needed to clear the Open and Close texfields and then re-add the data before this worked.

  1. Click Language->Define your language... in the drop-down menus.

An arrow points to the "import" button.

  1. Click Import..., as seen.

A partial URI is shown; an arrow and question mark indicate that PHP has not been contributed; the Javascript UDF file is indicated by a second arrow; "activate the okay button" is indicated by a third arrow.

  1. Browse to User-Defined Language Files (docs.notepad-plus-plus.org) and find your UDF; as seen in the image above, PHP has not been contributed; however, JavaScript has been contributed, and it's much better than the built-in JavaScript Language file (I recommend trying that so click Okay).

A drop-down select is indicated with a first arrow containing the UDF name; a second arrow points to a checked checkbox that reads "Allow folding of comments"; a third arrow points to the "open" field in in the "comment line" pane; a fourth pair of arrows points to the "open" and "close" fields in the "comment style" pane.; a fifth arrow indicates activating the "undock" button.

  1. Under the Comment & Number tab, make sure the imported language is selected in the User language: drop-down menu. Also, make sure Allow folding of comments is checked. Single-line and in-line comments go under Comment line style and Multi-line comments go under Comment style; this way, if you do multiple single-line comments, they will fold.

Usage

alt + h may decrease horizontal scrolling by reducing line depth. alt + h maximizes editor-zooming FOV.

Code-folding improves editor-zooming FOV.

Non-hidden comments are unrelated items; hidden comments are code explanation.

Share:
14,643
finspin
Author by

finspin

Updated on August 09, 2022

Comments

  • finspin
    finspin over 1 year

    I have an HTML file with quite many comments. They are useful but I'd like to hide them when I'm working with file to make it easier to read.

    Have you come across a plugin that can do that? How about some other editor than Notepad++?