Community
    • Login

    Appending with numbered lines in xml

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 397 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.
    • Damien MoateD
      Damien Moate
      last edited by

      Hi I was hoping someone could tell me an easy way of adding numbers in sequence into an existing document.
      For example I have over 600 lines of data and want to add a line between every 2 lines to easily see some coordinates.
      Here is what I currently have:

      <!--							-->
      	<group name="BetterClutterCutter1x1" pos="4557.200684 6.081481 2434.070313" rpy="-0.000000 -0.000000 108.946159" a="-18.9462"/>
      	<group name="BetterClutterCutter1x1" pos="4447.911133 6.435289 2471.539551" rpy="-0.000000 -0.000000 -71.058342" a="161.058"/>
      	<!--							-->
      	<group name="BetterClutterCutter1x1" pos="5660.784668 54.345013 2303.892334" rpy="-0.000000 -0.000000 -76.362091" a="166.362"/>
      	<group name="BetterClutterCutter1x1" pos="5702.687988 53.958931 2332.832764" rpy="-0.000000 -0.000000 167.341461" a="-77.3415"/>
      	<!--							-->
      	<group name="BetterClutterCutter1x1" pos="5775.109375 62.346703 2471.519775" rpy="-0.000000 -0.000000 151.500793" a="-61.5008"/>
      	<group name="BetterClutterCutter1x1" pos="5730.605469 62.313519 2468.265625" rpy="-0.000000 -0.000000 1.907229" a="88.0928"/>
      	<!--							-->
      	<group name="BetterClutterCutter1x1" pos="5695.575684 70.593521 2573.979004" rpy="-0.000000 -0.000000 -178.875153" a="-91.1248"/>
      	<group name="BetterClutterCutter1x1" pos="5695.410645 70.044113 2533.210938" rpy="-0.000000 -0.000000 -88.224052" a="178.224"/>
      	
      

      And here is what I need:

      <!--							1-->
      	<group name="BetterClutterCutter1x1" pos="4557.200684 6.081481 2434.070313" rpy="-0.000000 -0.000000 108.946159" a="-18.9462"/>
      	<group name="BetterClutterCutter1x1" pos="4447.911133 6.435289 2471.539551" rpy="-0.000000 -0.000000 -71.058342" a="161.058"/>
      	<!--							2-->
      	<group name="BetterClutterCutter1x1" pos="5660.784668 54.345013 2303.892334" rpy="-0.000000 -0.000000 -76.362091" a="166.362"/>
      	<group name="BetterClutterCutter1x1" pos="5702.687988 53.958931 2332.832764" rpy="-0.000000 -0.000000 167.341461" a="-77.3415"/>
      	<!--							3-->
      	<group name="BetterClutterCutter1x1" pos="5775.109375 62.346703 2471.519775" rpy="-0.000000 -0.000000 151.500793" a="-61.5008"/>
      	<group name="BetterClutterCutter1x1" pos="5730.605469 62.313519 2468.265625" rpy="-0.000000 -0.000000 1.907229" a="88.0928"/>
      	<!--							4-->
      	<group name="BetterClutterCutter1x1" pos="5695.575684 70.593521 2573.979004" rpy="-0.000000 -0.000000 -178.875153" a="-91.1248"/>
      	<group name="BetterClutterCutter1x1" pos="5695.410645 70.044113 2533.210938" rpy="-0.000000 -0.000000 -88.224052" a="178.224"/>
      	
      

      It doesn’t have to be exactly like that but some sort of easy to read numbers that are commented out, which is what the <!-- --> is for.
      Any help much appreciated!

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Damien Moate
        last edited by

        @damien-moate ,

        Thanks for the before/after example; it helps us help you.

        The search engine (Find/Replace dialog) does not know how to count, so it cannot be done solely with find/replace.

        However, there are a couple of ways of doing it inside Notepad++, if you’re willing to use a plugin, or a multi-step process.

        If you like programming/scripting, you can use the PythonScript or similar plugins; there are examples of similar activities if you search the forum for add_1

        However, if you really have the <!-- --> comment lines every third line, as shown in your example, I would do the following:

        1. FIND = \R(?!\h*<!--), REPLACE = ☺, SEARCH MODE = Regular Expression
          • This will condense each group of 3 lines into one long line.
          • I picked ☺ because that’s not likely in your document already, and it will make the final step really easy
        2. If the first line is really indented differently than the others, as you’ve shown, then you will want to indent the first line to match.
        3. Use Alt+drag next to the --> on each line to “column select”:
          5cce2e32-7c36-4667-8ee4-f3fbb7924dd8-image.png
        4. Edit > Column Editor, click ⦿ Number to Insert, Initial Number = 1, Increase By = 1, OK
          6f5896ec-a00e-4d1b-9896-2490e866ddce-image.png
          3030c347-959c-4467-9a0b-608d8759d9ee-image.png
        5. FIND = ☺, REPLACE = \r\n, SEARCH MODE = Regular Expression
          1859ed77-ecff-472b-a6b3-cd98d2251171-image.png
        1 Reply Last reply Reply Quote 4
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors