Community
    • Login

    Use of Mathematical equations between two highlighted amounts.

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 225 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.
    • Hemant NaikH
      Hemant Naik
      last edited by

      I want to find a difference between the two amounts in my notepad++ after I highlight them.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Hemant Naik
        last edited by

        @Hemant-Naik ,

        Notepad++, as a text editor, will not do calculations for you, natively.

        That said, there are certain plugins that could help – for example, Expression calculator or NppCalc (NppCalc is only available for 32bit Notepad++, so if you have 64-bit, it will not show up in Plugins Admin and won’t work even if installed manually.)

        Or you could use one of the scripting plugins (PythonScript is usually the one mentioned here, but LuaScript or others should be able to handle it as well) and write a script that will take the contents of a multi-selection and apply some mathematical operation on them.

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

          As a few lines of PythonScript, it could be a simple as:

          num1 = int(editor.getTextRange(editor.getSelectionNStart(0), editor.getSelectionNEnd(0)).strip())
          num2 = int(editor.getTextRange(editor.getSelectionNStart(1), editor.getSelectionNEnd(1)).strip())
          print(num1 - num2)
          

          But of course there are always concerns about error checking (what if there aren’t two selections…what if selected text isn’t numeric…etc) and then also is integer math sufficient, or is floating point wanted…

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