Community
    • Login

    Footer Sel: to include word count

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    4 Posts 2 Posters 5.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • WhoCanDoW
      WhoCanDo
      last edited by

      Hi,

      In the footer of Notepad++, can someone modify Sel: to include a word count please?

      Yes, I know word count is in “Find” but wouldn’t it be great if you could highlight a selection and know straight away how many times that selection occurs. Currently “Sel:” shows how may letters and how many lines are selected. Someone must have a use for that but I can’t figure out why.

      It would be great to see if I have declared variables that I haven’t used, or to see quickly if the variable I have used is just in the local block or elsewhere in the code.

      Thanks :-)

      Scott SumnerS 1 Reply Last reply Reply Quote 1
      • Scott SumnerS
        Scott Sumner @WhoCanDo
        last edited by

        @WhoCanDo said:

        …see if I have declared variables that I haven’t used, or to see quickly if the variable I have used is just in the local block or elsewhere in the code

        So this part it totally different from your topic title and the rest of your posting, and for it you have a few options currently available:

        • Use the Smart Highlighting feature (double-click a word/variable to smart-highlight it, then use the mouse ONLY to navigate to other regions of the file to see (or not) other occurrences of the same word/variable highlighted); must be enabled in Settings (menu) -> Preferences… -> Highlighting (box on left) -> stuff on right
        • Use the Search (menu) -> Mark… feature to see all of your desired text highlighted in red
        • Use one of the Search (menu) -> Mark All -> Using ___ Style features to see all of your current word/selection text highlighted in one of 5 different colors
        Scott SumnerS 1 Reply Last reply Reply Quote 0
        • Scott SumnerS
          Scott Sumner @Scott Sumner
          last edited by

          @Scott-Sumner said

          So this part it totally different…

          Okay, so on 2nd thought I can see how your entire post ties together but the earlier recommendations still stand as good techniques for the “variables” thing.

          If you are looking for comments or workarounds:

          As far as dynamic updating goes, you are currently out of luck for having this happen without scripting help (see below); concerning on-demand techniques (where you do something to get the data you seek) I see the following options:

          • Word count is NOT in Find directly…match count is…of course if you tell it to match a regular expression of \w+ you will get a word count of the entire doc
          • For a word count in a selection you can do a Replace All (with In selection ticked of course) and regex replace \w+ with $0…then take note of the status bar of the Find/Replace window and it will show you the word count in the form of replacements made (text itself won’t be changed although the document will be modified). You can record this as a macro to lessen the pain, but you still have to run the macro so this is still and “on-demand” thing.
          • View (menu) -> Summary will give you a word count (not in selection but rather in the whole document); just pointing that out in case you didn’t know

          Scripting:

          If you are open to using the Pythonscript plugin (currently 32-bit only):

          • For something similar but a little bit different, see https://notepad-plus-plus.org/community/topic/14144/is-there-a-way-to-customize-the-status-bar-to-display-more-helpful-information

          • I thought I had posted the code below before but I can’t find a link to it now; anyway I think it does exactly what you want, I call it WordCountInSelAlwaysInStatusBar.py:

            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])

          If you are just making a feature request here is some advice:

          Your best option is to make a feature request or a change-in-functionality request here: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/ by opening a “New issue”.
          However, please spend a little time searching to see if your specific request already exists, in which case you can “up-vote” that Open Issue so that in theory it gets more attention. You may also add to an already open Issue any new information you think relevant.
          You may search open issues (at the above link) as follows:

          • Make sure the Issues “tab” is active
          • The box to the right of the Filters dropdown (with the magnifying glass in it) should already have is:issue is:open in it
          • Add a space and then your search term to that box and press Enter
          1 Reply Last reply Reply Quote 0
          • WhoCanDoW
            WhoCanDo
            last edited by

            Excellent information Scott. Thanks for the great ideas.

            1 Reply Last reply Reply Quote 1
            • Alan KilbornA Alan Kilborn referenced this topic on
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors