Feature request: Copy line with number
-
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!- Copy “line numer” space “body of line”. Result:
222 this i line text,line number 222!
- Copy “line numer” space+space “body of line”. Result:
222 this i line text,line number 222!
-
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\3So 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 signtogether 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 newlineIs this what you are looking for?
Cheers
Claudia -
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)) -
Do you refer to the line numbers here
and you want, for example, copy linewhile (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 -
@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. -
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 -
@Claudia-Frank said:
Platform
Thank you Claudia :-)