Closed abdekker closed 5 years ago
I subscribe to this request.
You can also access the Summary by double clicking on the status bar. Still, I would also love to see the word count without interacting!
@joergneulist: Thanks! Did not know about that. The original feature request is still valid, but this is useful (hidden) feature.
+1
+1
I use the double click method, but for me, if I could just glance at the status bars and clearly see the word count it wouldn't break the flow of writing.
Vote for this feature
Absolutely! Please do this!
+1 from me. Would be very progressive in workflow.
+1 -- or even better, a customizable status bar would be great.
Can I request the number of words selected get counted and displayed automatically in the bottom info bar? Everything else I wanted has been fixed and this program is wonderful. This would be very useful for students submitting homework that need to be certain lengths. As well as university students and SEO (Search Engine Optimization) workers like me that need to also find text throughout multiple files.
Like this: selected count/total count
Maybe I'm off base here but perhaps an idea on why this hasn't been implemented is that it could be "expensive" to calculate the number of words in a really large document. The standard things currently shown on the status bar are all direct Scintilla calls to data items that are already maintained.
Word and Open Office can easily do this. It can't be that taxing on a modern day PC to do a word count. The total count is already built in and counting selected words in text when being selected isn't millions of words. It's just the words selected.
Where is the code for the summary word count and the toolbar currently?
@a4jp-com It is not advisable to compare Word or Open Office to Notepad++; apples and oranges. As a raw assignment (won't use the word "task" here), it's not "taxing on a modern day PC"--however it would have to be "architected" in. THAT part may or may not be "easy". It is certainly easy to say "just (count) the words".
@a4jp-com said "Where is the code for the summary word count and the toolbar currently?"
If you are a programmer it might occur to you to search the project for a string such as:
Characters (without
which should lead you very near the area you are asking about. Not sure, though, didn't try it...
It would be great if the word count can be shown on the status bar
+1
+1
Love Notepad++ and use it everyday, but it always bugs me to not have this simple feature
I was just googling how to do this in Notepad++ a couple days ago... I expected it to be on the status bar, and it wasn't obvious how to find that information. I think this would be a great enhancement.
It can't be too difficult to implement something like this. Anyone know a programmer that can help?
@a4jp-com a straight forward implementation is probably not too difficult. However, I suspect it is quite challenging to make it efficient enough so that users don't notice any slowdown while editing.
Is there any way to get a beta version of the program made? To see if it actually slows things down? I guess unless anything is made no one will actually know if the program is slow or be able to find out why it is slow.
Adding a selected word count feature into a left click menu after something is selected would be another way to deal with it if the status bar is no good. Or a popup that says this standard feature is turned on in options but you can turn it off to speed up the program if you like.
Even the plugin has no problems at all counting words or characters.
If a counter was slow, it could be set up so it doesn't interfere with the actual program too, right? Sorry if I'm looking at this in the wrong way, I'm only used to making web based things. What code has this program been made in? C++?
Here is some sample code for C/C++, Java, Python, C#, and PHP: https://www.geeksforgeeks.org/count-words-in-a-given-string/
Optimizing GetStyleAt(): https://github.com/jacobslusser/ScintillaNET/issues/32
Word Counting in C++: Implementing a Simple Word Counter: https://www.fluentcpp.com/2018/10/12/word-counting-cpp-simple-word-counter/
I'm happy with the plugin I have now but it took ages to find it before and it would be great if a basic selected text word counter was added somehow. Even just having the plugin load in when the program loads would be cool. People can then disable it if they like.
So maybe the discussion of this issue is getting a little too bogged down in my early comment about it being slow. It is all a matter of scale. If you edit mainly small files, having something constantly counting all the words and presenting that on the status bar is no big deal. However, some people use Notepad++ to edit huge files (the largest it can handle), and in those cases having something constantly doing an action like this could be prohibitive. So these users would start crying "Why did N++ get so slow?!". I'm just saying this is a potential concern, not that it surely would happen. It all gets back to architecture and design concerns, rather than just saying "this surely must be easy to implement!". It is much better to be an on-demand feature that you summon up when needed, rather than always happening. So we already have it in View->Summary; it just needs to be implemented for a selection when a selection is active when invoked.
+1
Double click on the "length/lines" zone of status bar will launch Summary. There'll be no word count on status bar.
Edit: No word count on status bar due to the performance issue.
I copy and pasted the entire Bee Movie script 105 times. It took approximately 3 seconds for the summary box to open on the resulting document as shown here:
This is a very long time yes, however the summary opened instantaneously when the document was only a single instance of the script as shown here:
My take away is that the potential CPU lag from tracking word counts on large documents in real time is a potential concern, however I have some recommendations.
The word count doesn't haven't to be up to the millisecond. The consensus request that I've inferred seems to simply pertain to work flow and creative flow. If the same word counter used in summary were set to automatically kick in/refresh when the user stops interacting with the text, it would still serve the requested function.
A maximum count for real time could also be implemented. The entire Lord of the Rings trilogy only contains 576,459 words and Stephen King's Under the Dome (a notoriously long read) only contains 299,280. Most people aren't going to require more than 200,000-300,000 even if they're writing exorbitantly long novels. Once the counter reaches a certain length, or if it's taking over a designated time to analyze, the function self disables, or switches to a longer sliding delay before refreshing. A color system can be utilized to designate when the count is up to date, for example: green = up to date, but then switches to red (out of date) once the user interacts with the text.
+1 Nicely described feature, heresjolly
On Wed, 19 Aug 2020, 09:26 heresjolly, notifications@github.com wrote:
I copy and pasted the entire Bee Movie script 105 times. It took approximately 3 seconds for the summary box to open on the resulting document as shown here: [image: image] https://user-images.githubusercontent.com/69891330/90602950-820fbe00-e1c8-11ea-88fa-fdc934cdf494.png
This is a very long time yes, however the summary opened instantaneously when the document was only a single instance of the script as shown here: [image: image] https://user-images.githubusercontent.com/69891330/90603126-cb600d80-e1c8-11ea-8b41-89a84e03a523.png
My take away is that the potential CPU lag from tracking word counts on large documents in real time is a potential concern, however I have some recommendations.
1.
The word count doesn't haven't to be up to the millisecond. The consensus request that I've inferred seems to simply pertain to work flow and creative flow. If the same word counter used in summary were set to automatically kick in/refresh when the user stops interacting with the text, it would still serve the requested function. 2.
A maximum count for real time could also be implemented. The entire Lord of the Rings trilogy only contains 576,459 words and Stephen King's Under the Dome (a notoriously long read) only contains 299,280. Most people aren't going to require more than 200,000-300,000 even if they're writing exorbitantly long novels. Once the counter reaches a certain length, or if it's taking over a designated time to analyze, the function self disables, or switches to a longer sliding delay before refreshing. A color system can be utilized to designate when the count is up to date, for example: green = up to date, but then switches to red (out of date) once the user interacts with the text.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/notepad-plus-plus/notepad-plus-plus/issues/1136#issuecomment-675901966, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYU5XDXOAC6BP2JDSQFLGLSBN5CTANCNFSM4BUDSXRQ .
There'll be no word count on status bar.
Yes, it'll be nice if I could switch between Length / Word count on status bar. +1
There'll be no word count on status bar.
Can you add the word count as an option in the right click menu (+ summary)? I would like to be able to select text and then right click bringing up and option to show details. Shortcuts only work when you can use both hands and the top menus aren't the best if you just wanna check the word count of different sections over and over. Any accessibility updates are greatly appreciated.
@a4jp-com said:
Can you add the word count as an option in the right click menu (+ summary)? I would like to be able to select text and then right click...
I attempted to add a change to the code for your need, but it was rejected. Thus I would suggest creating a macro for it, following these steps:
Word count in selection
)contextMenu.xml
:
<Item MenuEntryName="Macro" MenuItemName="Word count in selection"/>
When you run your macro, you will see the results here (example for 5 counted words in some selected text):
Some limitations with this approach:
If these limitations bother you, you can substitute the following, for the similarly numbered steps above:
2a. Open the Find window by pressing Ctrl+f 3a. Set up the Find window as follows: 5a. Press the Find All in Current Document button
When you run the "a" version of the macro, you will see the results here:
I can't see why they would block the update unless the code was buggy. That gets around the complaints of slow counts if people have large blocks of text. Opening the file is gonna take a long time anyway if there are millions of characters, right? I'm okay even if the useful toolbar count can't be implemented as the coding engine of this program is super slow. I just never thought a text editor would be so slow. If the code is super slow, can it be ported to a better coding system then?
Thank you so much for your try @sasumner Can you post the code here so we can work on it? This program is great but terrible when it comes to anything that needs a set number of words or characters. Like SEO work. Especially without a quick way of checking the numbers of words in a block of text quickly. Also checking files when they have to have paragraphs of a certain length. We just want a one or two click option if possible. @sasumner do you think your code could be made into a plugin?
@a4jp-com
I don't understand your first paragraph. Notepad++ is know for its "speed"; recently I saw a post where someone switched from VSCode to Notepad++ because VSCode was very slow. If N++ is slow for you, perhaps open an issue where you describe your circumstances.
Can you post the code here so we can work on it?
What code do you mean? The macro definition from shortcuts.xml
?
do you think your code could be made into a plugin?
For this you mean the C++ code I did in the (rejected) PR?
Adding reject label to perhaps discourage people from re-requesting this feature.
So... I need this feature as well and switched to vim. Good luck with N++, @sasumner
@igavronski what is Vim? I'm happy to switch apps if a proper word count isn't being added to Notepad Plus Plus.
I was told Notepad Plus Plus is slow and that is why they didn't want to add the count to the toolbar as an option or feature. I can't see why having it as an option that can be turned on or a plugin would be bad though.
@sasumner not the macro but the C++ code you made. I'm sure a it will help lots of people if it is available and working. I'm happy to try another apps if something out there already does this though. I like Notepad Plus Plus but like Blender prefer stuff that can be made user friendly with components that make work quicker.
IMO something like this not being a native feature is an insane reason to switch away from Notepad++, when there are so many ways to "make it happen".
@a4jp-com said:
I was told Notepad Plus Plus is slow
Do you believe everything you hear, or do you make judgments for yourself?
not the macro but the C++ code you made The C++ code I did is in PR #8791.
I'll work up yet another way to do this, using the Pythonscript plugin....
I said:
I'll work up yet another way to do this, using the Pythonscript plugin....
Oh wait, I already did that, over 2 years ago; see THIS from earlier in this thread.
That Pythonscript plugin looks wonderful and just what I was looking for @sasumner. Thanks for your patient support here as people struggle to understand why this couldn't be a feature (conditional on filesize perhaps). Should the Pythonscript code still work? I've added it as a script in N++ 7.9 but it doesn't seem to show up on status bar when selecting text. (A first copy-paste gave me a Unicode error in the Python console, but after fixing the apostrophes it seems to run, yet displays nothing.)
@mdingemanse
The way that script was posted was poor, but it should still work once format and indentation problems are solved. Here's a more properly formatted version of it that I tested:
# -*- coding: utf-8 -*-
from Npp import editor, notepad, SCINTILLANOTIFICATION
import re
def WCISAISB__callback_sci_UPDATEUI(args):
if args['updated'] & UPDATE.SELECTION:
text = editor.getSelText()
notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, 'Word count in selection: {}'.format(len(re.findall(r'\w+', text))) if len(text) > 0 else ' ')
editor.callback(WCISAISB__callback_sci_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])
@sasumner thanks for making that.
Thought I'd introduce a new take on this, one that gives both the wordcount in the selection and the wordcount in the entire document. As an added bonus, it only recomputes the count when a new buffer is activated or the user actually modifies the file, which should improve performance. It also doesn't overwrite the document type section.
from Npp import editor, notepad, STATUSBARSECTION
from Npp import SCINTILLANOTIFICATION as SCN
from Npp import NOTIFICATION as NPPN
wordcount = 0
selected_wordcount = 0
def on_match(m):
global wordcount
wordcount += 1
def on_selection_match(m):
global selected_wordcount
selected_wordcount += 1
def get_wordcount(args):
global wordcount
if args.get('modificationType') or args.get('bufferID'):
# doc was modified or new doc was opened; refresh count
wordcount = 0
editor.research('\w+', on_match)
# add wordcount to status bar along with other info
doclen = editor.getLength()
doc_bar_desc = 'length: %i lines: %i words: %i' % (
doclen,
editor.getLineCount(),
wordcount
)
notepad.setStatusBar(STATUSBARSECTION.DOCSIZE, doc_bar_desc)
sel_start, sel_end = editor.getUserCharSelection()
curloc = editor.getCurrentPos()
curline = editor.lineFromPosition(curloc) + 1 # 1-based indexing
curcol = editor.getColumn(curloc) + 1
sel_size = sel_end - sel_start
if 0 < sel_size < doclen:
# get wordcount in selection, add to status bar
global selected_wordcount
selected_wordcount = 0
editor.research('\w+', on_selection_match, 0, sel_start, sel_end)
start_line, end_line = editor.getUserLineSelection()
selection_desc = 'Ln : %i Col : %i Sel : %i Lines : %i Words : %i' % (
curline,
curcol,
sel_size,
end_line - start_line + 1,
selected_wordcount
)
notepad.setStatusBar(STATUSBARSECTION.CURPOS, selection_desc)
try:
MODULE_ALREADY_INITIALIZED
except:
MODULE_ALREADY_INITIALIZED = True
try:
CALLBACK_ALREADY_ADDED
except:
get_wordcount({"modificationType": 1})
editor.callback(get_wordcount, [SCN.UPDATEUI, SCN.MODIFIED])
notepad.callback(get_wordcount, [NPPN.BUFFERACTIVATED])
CALLBACK_ALREADY_ADDED = True
Strong +1 for this much-needed feature!! Selecting part of the text and being able to see word count for just the selected text would be a dream come true!
@antanji
It isn't going to become a feature in the standard product (or it would have been done some time ago). Go with one of the scripting options above and have your desired functionality TODAY.
Strong +1 for this much-needed feature!! Selecting part of the text and being able to see word count for just the selected text would be a dream come true!
Yeah. It would be nice if it was built in and had an option so it could be turned off for people that don't wanna count characters. I think the version I have now is working from the code I added so I think I just forgot about it but it's a super useful feature.
@xomx Do you want it to count special characters? Maybe a double click could open a window giving an option for the type of characters we want to count.
Do you want it to count special characters? Maybe a double click could open a window giving an option for the type of characters we want to count.
Given that word-count on the status bar is not likely to be implemented... This comment might serve better as a feature request for the View menu's Summary command.
Using v6.3 here. Currently the status bar has a panel that says "length : 31003 lines : 507" (in my example). The number of bytes is interesting but in some circumstances not of interest, whereas the number of words might be. My suggestion is to be able to toggle between "file size" and "word count" in the status bar. The status bar would then appear as:
I realise there is the menu option View > Summary... gives some of this information, but that's a bit buried away and requires several clicks.
Great job on notepad++, love it!