• Login
Community
  • Login

Use of Mathematical equations between two highlighted amounts.

Scheduled Pinned Locked Moved General Discussion
3 Posts 3 Posters 226 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.
  • H
    Hemant Naik
    last edited by Jun 11, 2024, 6:32 PM

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

    P 1 Reply Last reply Jun 11, 2024, 6:41 PM Reply Quote 0
    • P
      PeterJones @Hemant Naik
      last edited by Jun 11, 2024, 6:41 PM

      @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
      • A
        Alan Kilborn
        last edited by Jun 12, 2024, 11:01 AM

        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
        2 out of 3
        • First post
          2/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors