Code folding
Notepad++ has code folding built in:
Code folding
Most programming languages support the notion of code block. When
Notepad++ detects a keyword or operator that starts a block, it
inserts a fold point, which shows on the fold margin.
You can click on such a symbol to fold/unfold the corresponding block.
Its first line is always displayed. Ctrl-clicking a folded point will
recursively unfold all blocks inside it.
Additionally, the View menu provides the following commands:
- Fold all blocks (Alt-0)
- Unfold all blocks (Alt+Shft+0)
- Fold this block (Ctrl+Alt+F)
- Unfold this block (Ctrl+Alt+Shift+F)
- Fold this block at level n (Alt+n)
- Unfold this block at level n (Alt+Shift+n)
The words "fold" and "collapse" are used interchangeably, and
similarly "unfold" and "uncollapse".
Topmost code blocks are said to be at level 1. Their direct sub-blocks
are at level 2 and so on. The block level must be a digit between 1
and 8. The default shortcuts use the top keyboard row, not the numeric
keypad. Note that the folding block where the current line lies is
highlighted on the fold margin. You can change the colour being used
using Settings -> Styler Configurator -> Global Styles , Fold active.
This will work with the box or circle folding block style only.
The shortcuts for folding and unfolding a level have the same
appearance on the Shortcut mapper. However, collapsing commands follow
Collapse current level, and likewise for uncollapsing.
Fold state for a document is recorded in session files so as to be
restored on reopening the document from the session.
Source Lines And Blocks
I would like to be able to visualize a .tex file in an outline
You will need to add Tex as a User Defined Language.
The easiest way to do this is to import a pre-built Tex UDL file.
There is one available at LaTeX Editing Using Notepad++:
Notepad++ is built on the Scintilla text-editing library, which
includes support for highlighting TeX files. I preferred to make some
changes to the style, and unfortunately this requires you to create a
user-defined language. The user interface to do this in Notepad++ is
under Language > Define your language.... Here you can specify your
own options and export them to a UDL (User Defined Language) XML file.
If you wish, you can import my UDL file for TeX and modify it to suit
your needs.8 To force Notepad++ to use your user-defined language when
opening TeX files, disable the built-in TeX processor by going to
Settings > Preferences... > Language Menu/Tab Settings and moving TeX
from the Available items list to the Disabled items list.
Note that by default you will not have auto-complete available for a
user-defined language. In order to correct this, you can copy the
tex.xml
file from your Notepad++ install (on my machine this is
C:\Program Files (x86)\Notepad++\plugins\APIs\tex.xml
) to a file
named userDefineLang.xml
in your settings folder (on my machine
C:\Users\<username>\AppData\Roaming\Notepad++\plugins\APIs\userDefineLang.xml
).
This is somewhat inelegant as the same auto-completion list must be
used for all user-defined languages. Notepad++ is not perfect.
Examples showing a .tex
file folded and unfolded.
It would also be useful for seeing the structure of other documents, like .html
That is built in. See Folding above.