Character count display as you type
-
Hello,
Preferably without having to download any third party plug-in:- Constant display of the character count as you type between 2 marks:
Currently you see it in the ‘SEL’ only when marking text, and as soon as you press a key it disappears. So instead of having to mark the text many times:
How to see constantly as you type the character count between 2 marks? (the marks can be tags/lines/character or whatever) - How to change the Default alignment from LTR to RTL and the contrary (i.e. without having to click Control-Alt-L/R every time when opening the np++)
Thanks in advance,
SF
- Constant display of the character count as you type between 2 marks:
-
This sounds like a pair of feature requests. If you think that we can implement code changes from this Community of Notepad++ Users, then you neglected to read the “Read this before posting” and the FAQs that it linked to, because this is not where feature requests are tracked.
Regarding my personal comments on these completely-separate topics:
-
You start by talking about “marking text” as if you meant selecting text. But “marking” and “selecting” are two different concepts in Notepad++.
- “selecting” is what you do by click-and-drag or shift+arrow; this affects what text you are actively editing; the developers are not going to change the behavior of Notepad++ to break the standard text-editor paradigm of “text that is selected is the text that will be edited on your next typed character or other manipulation”
- “marking” happens from the Search > Mark dialog (or similar methods of getting to that same dialog), and will only colorize matches (and maybe add the “Bookmark” notation for easy navigation). That’s solely a way of coloring text that is found in a search-like action
- there’s a third similar action, Search > Style All Occurrences of Token or Search > Style One Token (and similar methods of getting to those same actions). That’s a way to have a few different colors of temporary text highlights.
- none of those is intended to be used for defining a “start” and “stop” for some specific action (in versions of Notepad++ more than a few years old, that was also confusingly called “marking”)
- to implement your request, the developers would have to track a fourth range to implement your desired action.
- opinion: While I can see there might be rare cases where it’s useful, I don’t see that it would be a generically-useful enough feature that it needs to be implemented in the main Notepad++ application. That kind of “extra” is exactly why the developer allows third-party plugins, so that people with more niche needs can download the plugin to provide features that not everyone needs. And that said, I’ve never heard of a plugin that currently exists that implements that feature.
- possible workaround: copy the sub-portion of text that you care about the sub-length; paste it into a new tab; do all your manipulation with Notepad++ showing the full length of that sub-portion of text; when done manipulating it, copy it and paste it back into your original document
- possible workaround: download the PythonScript plugin or one of the other scripting plugins; write a script which implements the functionality you want. (I thought about it for a few minutes: I think probably making use of the “Style One Token” action for marking it, because that maintains the start and end locations for the token even as you edit inside that token; so then the PythonScript would just have to watch for the start and end locations of that token, and update some status occasionally
-
Default LTR/RTL:
- the option to define the default text direction doesn’t currently exist in Notepad++; I just searched through the open issues in the feature request section of the project repository: it exists as issue #9665; you might want to go add your support to that request; at one point, Don assigned it to himself to work on, but it looks like he forgot about it (and since the original requestor left GitHub, the original requestor won’t be pestering Don occasionally to remind him about it).
- I don’t know of any plugins that do this natively
- Since those menu commands affect every opened tab, using the PythonScript plugin, it would only take a couple of lines of code to have PythonScript change the direction every time you load Notepad++: edit PythonScript’s
startup.py
to runeditor.menuCommand(MENUCOMMAND.EDIT_RTL)
and set PythonScript configuration toAT STARTUP
instead ofLAZY
). Restart Notepad++, and it will be defaulted to RTL.
addenda: part 2 of this question is quite similar to this recent topic; I am cross-linking because developments in one may interest readers of the other
-
-
@PeterJones I first had to know whether these features exist. I think these are far more useful than you guessed e.g. when replying to websites that limit your text size and after some time suddenly get refreshed, you don’t want to lose your text so instead you write in a char.counting editor then paste it and send.
Workaround 1: I hadn’t seen that the npp shows the char.count, and now also tried your suggestion to open a new tab, the closest thing I saw there is the Pos for which you have to stop yourself every time and then go back to the same character which you left.
Workaround 2: Trying to style some partial word didn’t show the cyan color as shown in the ‘using 1st style’, inclduing after trying to enable global color in the style configurator. How to see that color, and since it allows you to style why its color isn’t seen by default? The issue however with a colored font is that the file may not be readable well by Word2010 or notepad, so I thought about adding simply a ‘user length symbol’ in which you can put some special char. say alt 0182, and while there are 2 such the char.count will appear. I guess that your developer can add it within a day easily.
As for the aligment, if you think how many people in the world use RTL you’ll realize that it’s certainly useful, and many need LTR for English mode.
Assuming that npp is fine for editing that file, the Win10 didn’t find it in/under the npp folder neither in the PF nor PF86, and in some other folder.
However, I guess that it takes 0 time (within a day easily) to add that such a field into the npp, and save it in a setup file which you already use.Thank you very much in advance.
-
@Shahar-F-un-monitored-mail said in Character count display as you type:
Workaround 1: I hadn’t seen that the npp shows the char.count, and now also tried your suggestion to open a new tab, the closest thing I saw there is the Pos for which you have to stop yourself every time and then go back to the same character which you left.
“Length”: The length is the number of bytes. But that’s a rough approximation for characters, especially in western scripts and as web-forms are likely to count them. For the Length, unlike Pos, it doesn’t matter where in the page your editing caret is, it will still show the total length.
Workaround 2: Trying to style some partial word didn’t show the cyan color as shown in the ‘using 1st style’,
Settings > Preferences > Highlighting: uncheck “match whole word only” for the “style all occurrences of token”. And please notice that I didn’t say or imply that the Token Styling would be sufficient; one would have to write significant code to go along with it in the Scripting language of one’s choice (or in the language where a new plugin was developed). That one would take effort, even for that workaround.
But I still think that the developer’s opinion would be that such a niche desire would better go in a plugin or script rather than in the core Notepad++ application.
inclduing after trying to enable global color in the style configurator.
In my opinion, the only good reason for ever using “global override” color is for people with vision issues (colorblind, needing high contrast in all situations, etc).
I guess that your developer can add it within a day easily.
Anyone who says that does not understand programming, especially for public-facing applications. Notepad++ has a large code base, and every change requires regression testing, and often adding new tests, and otherwise making sure that it doesn’t somehow interact or interfere with other features (let alone the complexities of starting on some “simple” change, and discovering as you go that it ended up being a lot more complex than you’d hoped). And then, of course, even without all that, the developer doesn’t release after every change; he waits for other features and bugfixes to be complete, until there’s enough of a change to justify the effort of a new release (because there’s a lot that has to be done at every release).
So even if someone officially requested that feature (which, as far as I know, no one has, yet), and even if the Developer thought it was a useful idea (which I somehow doubt he would; it seems to me to be the kind of thing he’d say would go better in a plugin), and even if he or one of the other volunteers decided to work on it, and even if they prioritized it over all the other features and bugs that exist in Notepad++, and even if they found some time when they weren’t working on their paying job instead of on this open-source off-hours volunteer project, it would still be a lot more than a day before you ever saw it in the application.
As for the aligment, if you think how many people in the world use RTL you’ll realize that it’s certainly useful, and many need LTR for English mode.
If you’ll re-read my post, I never said or tried to indicate that I thought that saving the default Text Direction was a bad or not-useful idea. Even though I have never had a need for it, I can easily see how it would be useful to a large group of users. I was just pointing out that the feature request exists, and that if you want to encourage the Developer to work on it, you should probably comment on that feature request.
However, I guess that it takes 0 time (within a day easily) to add that such a field into the npp, and save it in a setup file which you already use.
While I agree that just adding a setting and saving a flag to config.xml isn’t a lot of code, there’s a lot more to adding a feature than just that.
-
Constant display of the character count as you type between 2 marks
possible workaround: download the PythonScript plugin or one of the other scripting plugins; write a script which implements the functionality you want
This is fairly easy to achieve, e.g., just a hint of how easy it could be:
def updateui_callback(self, args): def match_found(m): self.sb_output(str(len(m.group(1)))) delim1 = 'StArTtExT'; delim2 = 'EnDtExT' editor.research(r'(?s)\Q{d1}\E(.+?)\Q{d2}\E'.format(d1=delim1, d2=delim2), match_found, 0, 0, editor.getLength(), 1)
This would display in the status bar the current number of bytes between two delimiter pieces of text (I just defined some silly ones).
If you’re interested in the full script, just let us know.
-
Appreciate the answers and I have no idea in scripts nor a way to check their safety for me;
Indeed the length can be a workaround, though temporary because still having to switch and possibly do copy-paste between screens (including for re-editing) may be little annoying, it also doesn’t have a field to define if Enter be counted as 0, 1 or 2 characters; Also if no one has asked for it before it still doesn’t mean that the relatively small number of people in the forum represents the world and that it’s not very useful or can become so;
Also I guess that since the npp has so many built in features/parameters, quite a few of them aren’t used or even known to most of the users;
As for times, I trust that you know well the npp dev process: is it correct to assume that if writing the 2 features requested i.e. Alignment saving & User length character, possibly with Enter length field 0/1/2 (which by themselves can at least be written within a day as build-in features) but only when there are enough features to be added together, the test is then performed once with all the features?
Thank you very much in advance.
-
@Shahar-F-un-monitored-mail said in Character count display as you type:
Appreciate the answers and I have no idea in scripts nor a way to check their safety for me;
If you don’t trust a script that you can read the source of, from and individual with extremely helpful contributions here in the Community for years, why would you trust it being in the source code of the application instead?
Indeed the length can be a workaround, though temporary because still having to switch and possibly do copy-paste between screens (including for re-editing) may be little annoying
If it’s for a form submission on a website, which is the use-case you described above, I don’t see why it would be multiple copy/pastes. But only you know what your workflow is.
it also doesn’t have a field to define if Enter be counted as 0, 1 or 2 characters;
No webform that I know of would count an Enter as 0 – a line wrap will be zero characters, but the Enter will count. As to whether it’s 1 or 2, that can easily be set by the active end-of-line style (editable by a right-click menu on the “Windows (CR LF)” or “Unix (LF)” that you probably see near the lower right of the status bar, or from equivalent Edit > EOL Conversion or context right-click menus.
Also if no one has asked for it before it still doesn’t mean that the relatively small number of people in the forum represents the world and that it’s not very useful or can become so;
But in my 7.5 years here and skimming the feature requests, I’ve never seen it. The lack of people making official feature requests is an indication that people don’t care enough about that feature to make it into an official request.
is it correct to assume … (which by themselves can at least be written within a day as build-in features)
As already stated, that parenthetical is already an unsafe assumption. For one, because no one (I repeat: no one, not even the owner of the project) is being paid to work on this. This is a hobby project for everyone involved, including the owner. Virtually nothing happens on the order of 1 day in this project.
but only when there are enough features to be added together, the test is then performed once with all the features?
That’s not what I said.
Assuming there are two feature requests (which there aren’t yet; and if you make only one feature request asking for both features, it will be rejected), and assuming someone decides to work on the feature requests (which is a big assumption), each feature will be implemented and tested before being submitted for review. Then the review will need to happen. Then, if the owner decides it’s good enough, he will merge the submitted code updates. There is testing and integration all throughout that process. Then, after it’s merged, it would be in the next release, whenever that happens to be. But since each of those steps can take days or weeks or more – and since the process can be rejected or halted or abandoned or forgotten about at any of those steps – I am trying to manage your expectations. Even if you do put in those two feature requests, and even if everyone who read them agreed that they were spectacular ideas, it doesn’t mean that they’d necessarily ever be started, finished, merged, or released.
Your best bet is to go the scripting route. I’ve already given you what’s needed for the script to defaulting to RTL on every run of Notepad++; Alan’s given you most of what’s needed for count-in-a-range script. If you’re unwilling to go the scripting route, then I wish you all the best of luck.
-
Oh I didn’t know that he’s a well known contributor to the npp, welcome to send the file with exact instructions for w10 (which btw was previously upgraded from w7, which may be the reason why the startup.py doesn’t seem to appear, at least in the standard folders for the alignment saving)
Btw do I have to first upgrade the current version from 2022 64b or perhaps uninstall and then re-install the latest stable release or no need
Thanks in advance, -
@Shahar-F-un-monitored-mail said in Character count display as you type:
welcome to send the file with exact instructions for w10 (which btw was previously upgraded from w7 which may be the reason
The instructions are identical for w7, w8, w8.1, w10, and w11.
why the
startup.py
doesn’t seem to appear, at least in the standard folders for the alignment saving)You need the PythonScript plugin. And you need to create your “
startup.py
(user)”. The instructions for installing the plugin, and for getting the user startup file if you don’t already have one, are found in our FAQ on PythonScript –Btw do I have to first upgrade the current version from 2022 64b
Probably not (though if you want to, that’s fine, too). Any recent version of Notepad++ should be able to handle this – I’d probably recommend v8 or newer, but other than that, it should all be compatible. And PythonScript v2.0.0 will work.