Appending with numbered lines in xml
-
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! -
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_1However, if you really have the
<!-- -->comment lines every third line, as shown in your example, I would do the following:- 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
- 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.
- Use Alt+drag next to the
-->on each line to “column select”:

- Edit > Column Editor, click ⦿ Number to Insert, Initial Number =
1, Increase By =1, OK


- FIND =
☺, REPLACE =\r\n, SEARCH MODE = Regular Expression

- FIND =
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login