No announcement yet.

How can I insert text from one file to the other?

  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I insert text from one file to the other?

    I'm trying to compare and modify two rather complex XML files.

    The problem I'm facing is that Beyond Compare doesn't correctly recognize a huge XML node that's present in one file but not the other. So BC intermingles existing lines from the sparse file with lines from the filled file:

    If I click the right file's yellow arrow, I'll be losing the lines BC has (falsely) recognised as matching content in the sparse file. So what I'm now searching for is a keyboard modifier key to tell BC to insert the block from the filled file into the sparse file at the position where the first line of the sparse block begins. I.e. no lines from the sparse file are supposed to be replaced. I want to add the lines from the filled file.

    I tried several modifier keys (<CTRL>, <SHIFT> and <ALT>) but non of them switched from Replace mode to Insert mode - at least that's what my observation was.

    Your help is appreciated.
    Last edited by SetTrend; 06-Sep-2016, 03:14 AM. Reason: corrected misspelling

  • #2
    If you're in "edit mode", you can hit the return key to insert blank lines at the cursor position. Then you can copy lines from the other file to those blank lines.

    If necessary, you can manually align the two files first, using right click >> Align With....


    • #3

      There are several strategies here. One is to use the right-click, Isolate command, to quick 'push' text out of alignment. You can then copy in either direction.

      Another is to alter the alignment algorithm to provide better results for your specific files. Should nodes ever align different lines in your XML files? The Session menu -> Session Settings, Alignment tab contains several options which may help parse and align your files, including different algorithms and a Never Align Differences option (which only works on Important text, which we can further customize with Grammar definitions). Do the alternate algorithms or Never Align Differences option help with these files?
      Aaron P Scooter Software


      • #4
        Thanks for helping me on this.

        I believe the Isolate option is the quickest and most intuitive of them all. I'll use that.

        Though I still feel it would be faster and even more intuitive to provide an Insert mode (by holding down <CTRL>) and a Remove mode (by holding down <SHIFT>) while clicking the yellow arrows.


        • #5
          It's a good suggestion, although I would recommend trying out the different alignment algorithms. Some work better for specific files or structure, and it's fairly quick to swap them in the Session Settings, Alignment tab. Defining a File Format's grammar for the important aligning element can also help influence the comparison. If this helps with even half of the cases automatically, that's 50% less manual isolation and alignment.

          Many of our settings and controls help control the comparison load. While it takes a little bit more setup up front, it hopefully means that all future comparisons load as expected with less manual tweaking needed. In more complex cases, we can even define a grammar for a key/node, mark other items as Unimportant, and then Never Align Differences. This would then cause only named nodes to align. This requires Ignore Unimportant Differences (Toolbar or View menu) to be disabled, so they appear as Blue and are still counted as a Difference for the comparison.
          Aaron P Scooter Software