0

I would like to go though all bookmarked lines and duplicate them.

This would be an automated way to pressing F2 then Ctrl+D.

I've tried macros and two \1 with find and replace with regular expressions.

---------------------Example before------------------------

hostname RTA 
interface Loopback0
 ip address 203.250.13.41 255.255.255.0
interface Ethernet0
 ip address 203.250.14.1 255.255.255.0
router ospf 10
 network 203.250.13.41 0.0.0.0 area 1
 network 203.250.0.0 0.0.255.255 area 0.0.0.0

there are 8 lines of code above. i bookmark lines 2 & 4.

------------------------Example after-----------------

hostname RTA 
interface Loopback0
interface Loopback0
 ip address 203.250.13.41 255.255.255.0
interface Ethernet0
interface Ethernet0
 ip address 203.250.14.1 255.255.255.0
router ospf 10
 network 203.250.13.41 0.0.0.0 area 1
 network 203.250.0.0 0.0.255.255 area 0.0.0.0
  • And both (macros and RegEx) works?!? ;) Can you be more specific? – g2mk May 31 '16 at 19:31
  • Both do not work, for example, if line 10 and 20 are bookmarked. i would like a line added into line 21 which is a copy of line 20. and a line added to line 11 which is a copy of line 10. – barryoff Jun 4 '16 at 23:00
  • Yep - it's a N++ bug... Remove bookmark as soon as possible in macro you are recording. – g2mk Jun 7 '16 at 5:36
0

My inelegant solution to this was to:-

-add "##BOOKmarked LiNe##" to each bookmarked line

-run the following in a vbs file

-remove all "##BOOKmarked LiNe##" entries.

outFile="C:\Users\user\Desktop\test_loop1-out.txt"
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFS = CreateObject("Scripting.FileSystemObject")

Set objFileout = objFSO.CreateTextFile(outFile,True)

Set objFile = objFS.OpenTextFile(strFile)

Do Until objFile.AtEndOfStream
strLine= objFile.ReadLine
objFileout.Write strLine & vbCrLf
if strLine.contains("##BOOKmarked LiNe##") Then objFileout.Write strLine & vbCrLf
Loop
objFile.Close
objFileout.Close

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.