Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    TextFX and word count

    General Discussion
    3
    9
    509
    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 Narins
      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?

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

        @Brigham-Narins ,

        See this FAQ

        Brigham Narins 1 Reply Last reply Reply Quote 1
        • Brigham Narins
          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 Kilborn 1 Reply Last reply Reply Quote 0
          • Alan Kilborn
            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 Narins 1 Reply Last reply Reply Quote 3
            • Brigham Narins
              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?

              PeterJones 1 Reply Last reply Reply Quote 1
              • PeterJones
                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 Narins 1 Reply Last reply Reply Quote 1
                • Brigham Narins
                  Brigham Narins @PeterJones last edited by

                  @PeterJones @Alan-Kilborn Thank you both

                  1 Reply Last reply Reply Quote 2
                  • Alan Kilborn
                    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 Kilborn 1 Reply Last reply Reply Quote 3
                    • Alan Kilborn
                      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
                      Copyright © 2014 NodeBB Forums | Contributors