Show total count of chars/words in statusbar
-
- Posts: 24
- Joined: 08.03.2023 07:48
Show total count of chars/words in statusbar
Thanks.
If you don't mind, I plan to reuse this thread to some minor questions not worth a dedicated thread. Starting with this one:
Do you know if there is a config or plugin to add chars and lines counter to status bar (maybe words too)? The same when there is a selection (count of chars, lines and words of the selected text). Other editors have this feature, like Notepad++, Kate, SciTE...
If you don't mind, I plan to reuse this thread to some minor questions not worth a dedicated thread. Starting with this one:
Do you know if there is a config or plugin to add chars and lines counter to status bar (maybe words too)? The same when there is a selection (count of chars, lines and words of the selected text). Other editors have this feature, like Notepad++, Kate, SciTE...
-
- Posts: 2306
- Joined: 25.08.2021 18:15
-
- Posts: 2306
- Joined: 25.08.2021 18:15
-
- Posts: 24
- Joined: 08.03.2023 07:48
Right, I'll do it if new questions arise.Please make a new thread- name it like "Minor questions about editor usage"
Thanks, but with the available _macros_ I was only able to add the total amount of lines (with {count}).Yes, read about options
ui_statusbar_str_sel
ui_statusbar_small_sel
ui_statusbar_no_sel
ui_statusbar_carets
they have about 20 _macros_.
It seems to be no way to get the total amount of chars, the total amount of words and the position of the caret in terms of chars or words.
Look at Notepad++ statusbar as an example:
Code: Select all
length: 17.646 lines: 475 | Ln: 44 Col: 28 Pos: 1.652
Other example, Kate statusbar:
Code: Select all
6/15:33, Words 18, Chars 242
Code: Select all
{current_line}/{total_lines}:{current_col}, Words {total_words}, Chars: {total_chars}
Specially the total of chars is important to me to be able to do a very quick and simple check if two files may be identical.
-
- Posts: 2306
- Joined: 25.08.2021 18:15
>It seems to be no way to get the total amount of chars, the total amount of words and the position of the caret in terms of chars or words.
To get it we need _slower_code, so they are absent. plugin "Text Statistics" shows this in a message box.
counting of words is slow.
and counting of total chars is slow - this needs counting ALL text lines, and if file is huge (50K lines) this needs (50K) additions.
counting of words is even slower! it needs looping over ALL text. how it will work on 50K lines text?
But this all can be added via plugin! if it uses on_change_slow, then it must be fast. ops, not 'fast' but no slowdown of work.
To get it we need _slower_code, so they are absent. plugin "Text Statistics" shows this in a message box.
counting of words is slow.
and counting of total chars is slow - this needs counting ALL text lines, and if file is huge (50K lines) this needs (50K) additions.
counting of words is even slower! it needs looping over ALL text. how it will work on 50K lines text?
But this all can be added via plugin! if it uses on_change_slow, then it must be fast. ops, not 'fast' but no slowdown of work.
-
- Posts: 24
- Joined: 08.03.2023 07:48
A possible optimization in this matter is to only count everything once: when loading the file. After that, it's cheap to just handle events. For instance, if a single char is typed with no deletion, just add +1 to char count, no need to count the entire text. If something was pasted, count just the pasted content and add its size to the counter...
Word might be a little more complex, but for me it's fine, I'm mostly interested in total chars.
Word might be a little more complex, but for me it's fine, I'm mostly interested in total chars.
-
- Posts: 2306
- Joined: 25.08.2021 18:15
-
- Posts: 24
- Joined: 08.03.2023 07:48
OK, fair enough. In any case, the suggestion remains for future consideration. At least char count visible in statusbar is almost universal across editors.
I did a quick task in Notepad++: copied the content of a file with 475 lines and 18k chars over and over until it surpassed 50k lines, with almost 2kk chars. It looks fine. Typing fast on a file that big has a bit of delay, not to the point of being annoying. And my guess is that the counter is not at fault.
I did a quick task in Notepad++: copied the content of a file with 475 lines and 18k chars over and over until it surpassed 50k lines, with almost 2kk chars. It looks fine. Typing fast on a file that big has a bit of delay, not to the point of being annoying. And my guess is that the counter is not at fault.
-
- Posts: 24
- Joined: 08.03.2023 07:48
Now I repeated the same task on SciTE and it's so smooth as if the file is empty. I can't notice any slowness, not even the minimal. And it has chars counter. The content of statusbar, for reference:
(it means current | total | selection)
If I make a biiig selection involving half of the content or almost all of it, counters update instantly. Of course I don't know the internal code, but *looks* and *feels* cheap, without any performance impact.
Code: Select all
Line 53558, Column 19 | 1940435 Chars, 53562 Lines | 0 chars, 0 lines | LF
If I make a biiig selection involving half of the content or almost all of it, counters update instantly. Of course I don't know the internal code, but *looks* and *feels* cheap, without any performance impact.
Last edited by pintassilgo on 10.03.2023 08:21, edited 3 times in total.
-
- Posts: 2306
- Joined: 25.08.2021 18:15