sidebar with lines i need to have reference to
-
Hi, is there a way in notepad++ to create a sidebar where i can see certain lines from the document i work on?
The document has lines beginning with keyword page. And i need to see on my left side these lines as gathered list. And when i click on the line in sidebar the document will jump to that line so i can edit text from there.
And everytime i type a next page line or delete page line the sidebar updates too.
Ideally if i could turn on/off the sorting of sidebar list by a-z order or unsorted order as it is typed in document.
-
@Sylfir-The-White said in sidebar with lines i need to have reference to:
The document has lines beginning with keyword page.
You could do a Find All in Current Document search for
^page
in Regular expression search mode:This would get your desired lines appearing in the Search results window, which provides double-click jumping to the source line. Here’s an example (I changed search to
^to
to search N++'slicense.txt
file):And i need to see on my left side these lines as gathered list
The Search results window appears by default on the bottom, but it can be undocked and moved where you like.
And everytime i type a next page line or delete page line the sidebar updates too.
Auto-update is probably unreasonable, but you could make a macro out of the search action and tie it to a keycombo, so one keycombo press updates the list.
sorting
Probably not an easy way to add in sorting to the mix.
-
Actually, using the Function List feature might be a better idea as it updates automatically, and has some sort capability. See HERE and look for info on how to customize the function list.
-
@Alan-Kilborn said in sidebar with lines i need to have reference to:
as it updates automatically
I should clarify that – it updates when the document is saved, not just “as you type”. So, a keypress is still involved to get an update.
Also, if you use the function-list approach, the
^page
regular expression I showed before is still useful, but you’ll probably want to capture what comes after that as well, to be displayed in the function-list panel. We can help with that if you get stuck and don’t know how to make that happen (after reading the docs I linked to earlier). -
I confirm, it is about function list. Looking at the docs it is about regex, which is kind of my problem too :-/. I found a lua regex and tried to do some experiments but nothing is seen.
a) i did not write the regex correctly
b) i need to set somewhere that the plotline.xml is connected to plotline syntax highlighter which i managed to setup correctlyYes, what i need to see in the list is something like this :
game.txt
page roomKitchen kitchen
page roomBalcony balcony
page itemBucketThis is what i seek. All commands are defined as lines. So everything else from page is thrown away when parsing to function list.
Here is the plotline.xml that i inserted into notepad++/functionList folder. Of course if i change it i restart the notepad and see if it works. This currently does nothing else and i have no idea if the class xml part i should remove, keep, or rework?
<?xml version="1.0" encoding="UTF-8" ?> <NotepadPlus> <functionList> <parser displayName="Plotline" id="plotline_function" commentExpr="--.*?$" > <!-- My own plotline engine supported --> <classRange mainExpr="[.\w]+[\s]*=[\s]*\{" openSymbole="\{" closeSymbole="\}" displayMode="node"> <className> <nameExpr expr="[.\w]+"/> </className> <function mainExpr="[.\w]+[\s]*=[\s]*['"]?[\w]+['"]?"> <functionName> <funcNameExpr expr=".*"/> </functionName> </function> </classRange> <!-- Basic lua functions support --> <function mainExpr="(\>page)" displayMode="$className->$functionName"> <functionName> <nameExpr expr="(\<page")+(A-Za-z0-9)* /> </functionName> <className> <nameExpr expr="[.\w]+(?=:)"/> </className> </function> </parser> </functionList> </NotepadPlus>
-
@Sylfir-The-White said in sidebar with lines i need to have reference to:
This currently does nothing
To get a function list for an arbitrary file type, for example your “plotline” type:
- You have to have a User Defined Language created for that type: for yours, name the UDL “Plotline” – it doesn’t need any formatting defined, just needs to exist (though the formatting might make it nicer to look at in the editor pane)
functionList\overrideMap.xml
must contain a reference to that UDL:<association id= "plotline.xml" userDefinedLangName="Plotline"/>
- you have to have the
plotline.xml
- restart Notepad++
- if you define the active file as Language > Plotline, then the Plotline FunctionList will try to work.
It often takes a lot of debug to get the FunctionList working the way you want it to. I usually start with a super-simple definition (like just looking for the word “page”), and get it to display just those… then I slowly expand it to more features (restarting after every update to the defnition).
-
Thx for the info you provided. I got it at least. It is just a simple “(page |rule ).*?$” regex after all.