notepad++ user defined regions with folding

ConfigurationNotepad++FoldingRegions

Configuration Problem Overview


I can't figure out how to configure notepad++ to display regions for user defined keywords.

I have a big trace file which shows the start and the end of a procedure. The trace file looks like this:

Beginn abc.def;
   ...
   Beginn ghi.jkl;
   ...
   Ende ghi.jkl;
   ...
Ende abc.def;

I would like to fold those regions like this:

[+] Beginn abc.def;

or

[-] Beginn abc.def;
       ...
[+]    Beginn ghi.jkl;
       ...
    Ende abc.def;

How do I configure my notepad++ to display this. Is it possible? Do you have any other suggestions?

Configuration Solutions


Solution 1 - Configuration

For version 6.5.5 and above:

Under the menu "Language" there is a menuitem called "Define your language..."

enter image description here

In the tab "Folder & Default" is a group called "Folding in code" where you can enter an "Open"- and a "Close"-Keyword.

Folding in code

For versions older than 6.5.5:

Under the menu "View" there is a menuitem called "User-Defined Dialog..."

View Define your language

In the tab "Folder & Default" you can enter a "Folder Open Keyword" and a "Folder Close Keyword"

Folder Open Close Keyword

Solution 2 - Configuration

Another simple way is just to add a comment marker followed by open-block to begin a block, and a comment marker followed by end-block to end a block. In C, C++, Java, Javascript, etc. it would look like this:

//{

//}

Solution 3 - Configuration

I have a similar problem. I want to add a custom tag like #region / #endregion to create arbitrary folding points in languages that don't support it. Specifically, I am trying to do this for php.

After researching for an hour or two, it seems that modifying an existing language is quite difficult due to the underlying scintilla lexer, and writing a plugin may be the only way to accomplish this.

I did discover however a decent workaround:

Wrap the code you wish to fold in comments like:

#{ 
...
#}

Then move your cursor before the open brace and press CTRL+ALT+b to highlight the entire block, followed by ALT+h to hide it.

It's a different operation than folding, but it works in a pinch.

Solution 4 - Configuration

I used Marcelo's answer to solve this for myself (in Perl), with one change...
If I included a space between the comment symbol and the bracket then it wouldn't work. It had to be placed immediately after:

#START example
################{

print "Hi there! ";
print "How are you?\n";

#}END example

Note that if I do:

#END example }

with the bracket after the text it won't work either

Solution 5 - Configuration

!! Disclaimer: Total noob at PHP !!

Assuming that you are wrapping your PHP in some HTML, you can define custom sections using <?php and ?>.

Ex:

<html>
<head></head>
<body>
<?php 
$cities[1] = "Phoenix";$cities[2] = "Tucson";$cities[3] = "Flagstaff";	
$capitals['CA'] = "Sacramento";$capitals['TX'] = "Austin";$capitals['OR'] = "Salem";	
$cities[] = "Phoenix";$cities[] = "Tucson";$cities[] = "Flagstaff";	
echo "Here are cities: $cities[1]";echo nl2br("\n");
?>
</br>
<?php
$cities = array( "Phoenix","Tucson","Flagstaff");	
$capitals = array( "CA" => "Sacramento","TX" => "Austin","OR" => "Salem",);
echo $capitals['TX'];echo nl2br("\n");	
?>
<body>
</html>

Notepad++ will then allow you to collapse the sections arbitrarily and you can label the sections with "#". Just learning PHP, so my code might not be awesome; It's still an ongoing process.

Solution 6 - Configuration

If it's SQL, then encapsulating your code with BEGIN and END works well. The BEGIN statement is shown, plus any comments you add on the same line.

e.g:

BEGIN --creating temp table with eligible users

   ...code

END

Solution 7 - Configuration

STEP ONE: Add a unique key with open and close (i.e.,

#1
{{{
#2
{{{
#2
}}}
##
}}}

Use indentation and/or comments to indicate nest-level.

Step 2: {CTRL}-H when you're finished. Replace all '{{{' and '}}}'.

STEP 3: Comment strip (app).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStephan SchielkeView Question on Stackoverflow
Solution 1 - ConfigurationStephan SchielkeView Answer on Stackoverflow
Solution 2 - ConfigurationMarcelo Teixeira RuggeriView Answer on Stackoverflow
Solution 3 - ConfigurationKevin JhangianiView Answer on Stackoverflow
Solution 4 - Configurationuser1881282View Answer on Stackoverflow
Solution 5 - ConfigurationITGuyOUView Answer on Stackoverflow
Solution 6 - ConfigurationjeminarView Answer on Stackoverflow
Solution 7 - ConfigurationWolfpack'08View Answer on Stackoverflow