• Login
Community
  • Login

Feature request: Copy line with number

Scheduled Pinned Locked Moved General Discussion
7 Posts 3 Posters 11.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.
  • P
    pwnotepaduser
    last edited by Nov 28, 2015, 5:11 PM

    Feature request: Copy line with number
    1.Copy “line nuber” and on new line copy “body of line”
    before:

    this i line text,line number 222!

    after:

    222
    this i line text,line number 222!

    1. Copy “line numer” space “body of line”. Result:

    222 this i line text,line number 222!

    1. Copy “line numer” space+space “body of line”. Result:

    222 this i line text,line number 222!

    1 Reply Last reply Reply Quote 2
    • C
      Claudia Frank
      last edited by Nov 28, 2015, 7:44 PM

      Hi pwnotepaduser,

      this can be achived using regular expressions (as long as the source lines are as you described).

      Open replace dialog and check regular expression

      E.g. No.1
      Find what should contain: (.*)(\d\d\d)(.)
      Replace with: \2\n\1\2\3

      So what is done here? Simple description
      With regex (.)(\d\d\d)(.) you looking for three groups, defined by ()()()
      (.
      ) = looking for everything
      (\d\d\d) = 3 digits
      (.) = one sign

      together it means: looking for everything until 3 digits occure and then one aditional sign.
      \1 get the result for (.*)
      \2 get the result for (\d\d\d)
      \3 get the result for (.)
      \n stands for newline

      Is this what you are looking for?

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • P
        pwnotepaduser
        last edited by Nov 29, 2015, 2:36 PM

        Claudia, no)
        Notepad++ have field with number of stings
        i need to copy string with number from one file to another.
        It is need to know what number of string i saved))

        1 Reply Last reply Reply Quote 2
        • C
          Claudia Frank
          last edited by Nov 29, 2015, 6:29 PM

          Do you refer to the line numbers here
          and you want, for example, copy line while (true) by providing the number 6, correct?
          If so, I guess it can be achieved by python script as long as you have installed, or willing
          to install, the python script plugin.

          If this is the case, let me know what you exactly want to do and I am certain we can
          write a little script.

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 1
          • P
            pwnotepaduser
            last edited by pwnotepaduser Nov 30, 2015, 6:11 PM Nov 30, 2015, 6:09 PM

            @Claudia-Frank said:

            for example, copy line while (true) by providing the number 6, correct?

            Yes it is, line with it number.
            My request is for notepad++ dev, to include this functional in program by right mouse click on mumber lines field.
            But if you do script - it will be good, for lifetime use.

            1 Reply Last reply Reply Quote 2
            • C
              Claudia Frank
              last edited by Claudia Frank Nov 30, 2015, 8:11 PM Nov 30, 2015, 8:08 PM

              Hi pwnotepaduser,

              to make this work you need to have installed python script plugin.
              Once installed goto Plugins->Python Script->New Script
              give it a name, I named it CopyByLineNumber, and press save.
              A new empty editor should appear.
              Copy the following into it and save it.
              I assume that you use an empty editor named “new 1”.

              # CopyByLineNumber.py
              TextToBeCopied = editor.getCurLine()        # save current line 
              notepad.open('new 1')                       # open tab with name new 1
              
              if TextToBeCopied[-1] != '\n':              # check if current line has a newline char at the end
                  TextToBeCopied += '\r\n'                # if not, add new line char at the end
              editor.appendText(TextToBeCopied)           # append text at the end of the new 1 doc
              

              To have it in the contextMenu you need to edit YOUR_INSTALL_PATH\Notepad++\contextMenu.xml.
              At the end add something like

                  <Item id="0"/>
                  <Item PluginEntryName="Python Script" PluginCommandItemName="CopyByLineNumber" />
              

              Item id=0 acts as a spacer and the next line is your script.
              Restart npp.
              Now when using right click you should have your script as an additional entry.

              You can also configure the script to appear as a button in the toolbar if you wish.

              I guess the most useful way to use it would be to use two views,
              otherwise you have to switch back from the “new 1” editor window always.
              Of course you can overcome this by adding a line in the script to open the
              original window at the end of the code.

              If the file, you use to save the copied text, is permanent, then you might modify the line

               notepad.open('new 1') 
              

              to something like

              notepad.open('C:\my_file.txt') 
              

              So, I guess that’s it.

              Have fun
              Claudia

              1 Reply Last reply Reply Quote 1
              • A
                AL Hasan Haj Asaad
                last edited by Feb 28, 2016, 1:07 PM

                @Claudia-Frank said:

                Platform
                Thank you Claudia :-)

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