Community
    • Login

    TextFX and word count

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 3 Posters 1.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.
    • Brigham NarinsB
      Brigham Narins
      last edited by Brigham Narins

      First of all, I just noticed that the TextFX plugin is gone, as though I removed it, but I didn’t. And it isn’t listed among the available titles in the Plugin Admin. Did I miss something in that last few days?

      The two main features I used in TextFX:

      1. Word count, particularly the ability to report the number of words in selected text
      2. Line sorting that eliminates duplicates

      Are these things available in other plugins?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Brigham Narins
        last edited by

        @Brigham-Narins ,

        See this FAQ

        Brigham NarinsB 1 Reply Last reply Reply Quote 1
        • Brigham NarinsB
          Brigham Narins @PeterJones
          last edited by

          @PeterJones Thanks. I know about the View > Summary for whole-file word counts, but it doesn’t count the words in selected text. If you know how to do that, or know of another plugin that does it, I’d appreciate it.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @Brigham Narins
            last edited by

            @Brigham-Narins

            Simple Pythonscript, called WordCountInSelectedText.py:

            # -*- coding: utf-8 -*-
            from __future__ import print_function
            
            from Npp import *
            import inspect
            import os
            
            #-------------------------------------------------------------------------------
            
            class WCIST(object):
            
                def __init__(self):
                    self.this_script_name = inspect.getframeinfo(inspect.currentframe()).filename.split(os.sep)[-1].rsplit('.', 1)[0]
                    self.total = 0
                    def match_found(m): self.total += 1
                    editor.research(r'\w+', match_found, 0, editor.getSelectionStart(), editor.getSelectionEnd())
                    self.mb('Words in selected text = {}'.format(self.total))
            
                def mb(self, msg, flags=0, title=''):  # a message-box function
                    return notepad.messageBox(msg, title if title else self.this_script_name, flags)
            
            #-------------------------------------------------------------------------------
            
            if __name__ == '__main__': WCIST()
            
            Brigham NarinsB 1 Reply Last reply Reply Quote 3
            • Brigham NarinsB
              Brigham Narins @Alan Kilborn
              last edited by

              @Alan-Kilborn Thank you! Running such a script is something I’ve never done in NPP. Can you point me to a section of the manual or give me simple instructions?

              PeterJonesP 1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @Brigham Narins
                last edited by

                @Brigham-Narins ,

                Running such a script is something I’ve never done

                We have a FAQ on that

                Brigham NarinsB 1 Reply Last reply Reply Quote 1
                • Brigham NarinsB
                  Brigham Narins @PeterJones
                  last edited by

                  @PeterJones @Alan-Kilborn Thank you both

                  1 Reply Last reply Reply Quote 2
                  • Alan KilbornA
                    Alan Kilborn
                    last edited by

                    Of course, it is arguably even easier to just set up a search and press the Count button in the Find window, like this:

                    efd7c109-68dd-4186-9545-9a1fdd821e79-image.png

                    The result is shown in the status bar of the Find window.

                    This can be macro-recorded for easy running; the downside is that to see the result, the Find window has to be open.

                    Alan KilbornA 1 Reply Last reply Reply Quote 3
                    • Alan KilbornA
                      Alan Kilborn @Alan Kilborn
                      last edited by

                      There’s also a way to put a selection’s word-count in the status bar; see HERE for that.

                      1 Reply Last reply Reply Quote 3
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors