Style Tokens are lost between sessions.
-
Style Token colors aren’t retained between sessions. When you close a session, the highlights are lost. How can I resolve this?
-
@Franklin-Márquez
Since you don’t appear to be writing a pointless angry tirade against Don Ho or Notepad++, I would recommend that you file questions like this under a different heading, rather than “Boycott Notepad++”.As far as retaining Style Tokens, I’m pretty sure it would be extremely difficult for Notepad++ to do this, because the styles are just temporarily held in memory by the Scintilla editor component; they’re not incorporated into the file that’s stored on disk, unlike in a Microsoft Word document. In short, Notepad++ is a text editor, not a word processor.
That said, I imagine you could create a macro to automatically highlight certain words/phrases/regex matches. Then you could just use a keyboard shortcut to highlight all the stuff you want as soon as you open a file. You could even use a scripting plugin to add a callback function that does this automatically when a file of a certain type is opened.
If you give us a little more information on your use case, somebody might be able to give you more help. Look on npp-user-manual {dot} org for more relevant documentation. Can’t link right now because at work and pressed for time.
-
Already has a Feature Request listed at Github.
FR: Remember Style all occurrences of token though the sessions
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12684As has been mentioned at Github, saving extra information like Bookmarks, other Markers, Style Tokens, … can become be out of sync once reload the file or file is modified between Notepad++ sessions.
@Mark-Olson mentioned Microsoft Word which saves all this extra information in the same file as the document so remains in sync.
Notepad++ in comparison uses a separate xml file to the document file that to update any saved information on close and restore the information on open. Notepad++ has no control over modifications to these document files while it is not in a running session and even during running can lose control once the reload occurs.
How can I resolve this?
You would need knowledge about Notepad++ workings, knowledge about Scintilla workings and good programmimg skills.
In Notepad++ with plain text files which can be modified externally, implementing anything to save extra information could be a total waste of time and effort, though that is just my opinion.
Notepad++ saves Bookmarks. Lets test this with an example with before and after image:
- Open new document.
- Type
Important line
at 1st line. - Bookmark line 1.
- Save document to an external file.
- Close Notepad++.
- Open file with another program.
- Insert
Inserted line
at 1st line. - Save document to file.
- Close program.
- Open Notepad++.
Indeed a problem exists with saving extra information in Notepad++ or any other plain text editor that follows the same logic that can go out of sync. If a user cannot trust it, then a user needs to verify it and to do that over and over is concerning enough that not saving the extra information might be a better experience.
-
@mpheath said in Style Tokens are lost between sessions.:
If a user cannot trust it, then a user needs to verify it and to do that over and over is concerning enough that not saving the extra information might be a better experience.
The “trust” issue could be solved by hashing the file and saving the hash in the sidecar file. If it didn’t match, you wouldn’t be able to recover the information (which would leave you in the same place you are now); but if it did restore, you’d know it wasn’t mucked up.
-
While hashing is a fine idea, it seems like a broad solution to the problem ahead. Hashing has no logic, it is basically match or mismatch.
If a line is modified and remains in the same line order, then the hash mismatch check will not restore Bookmarks, … at Notepad++ startup for that document. Just 1 byte change will affect the hash.
Users will tend to trust Notepad++ to restore the extra information like Microsoft Word does , yet might be disappointed that Notepad++ does not restore based on hash mismatch. All the extra overhead to gather the extra information will be for nothing if not restored.
The hashed feature reminds me of a tease. You might get the extra information restored or you may get no extra information restored. Get punished if you use anything other than (the same single) notepad++.exe to modify the document file.
I personally would not trust a feature that may work sometimes based on the matching of a hash. Though some others might accept the gamble.
-
@mpheath said:
Already has a Feature Request listed at Github.
And if I’m remembering correctly, the Notepad++ author has stated that “style” information won’t be saved.
-
Hello, @franklin-márquez, @mark-olson, @mpheath, @alan-kilborn and All,
Alan, did you forgot of your excellent
Python
script which is able, given a fileTest.txt
, to save its stylings in a related file namedTest.sty
, saved in the same folder and to restore these stylings as soon as theTest.txt
is opened or reloaded ?!Refer to https://community.notepad-plus-plus.org/post/81755
I suppose that this solution could fully satisfy the OP !
Best Regards,
guy038
-
G guy038 moved this topic from Boycott Notepad++ on
-
@guy038 said:
did you forgot of your excellent Python script
I didn’t exactly forget… :-)
But some of the earlier comments in this topic have made me decide that it might be best to just not try to remember any previous styling. I’m even doubting remembering bookmarks now too. :-)