I love using WinSCP for so many reasons. One of the many really cool features of WinSCP is the ability to add custom commands. In this article, I will describe how to integrate WinMerge into WinSCP to compare a local version of a file to a remote version.

When comparing online and offline source code files, the process is typically to download the online file over FTP or SCP using WinSCP and then compare that to a local version of the file using some file comparison tool or eye-balling the two files in a code editor by flipping back and forth. Doing this once in a while isn't too inconvenient but if you need to compare online and offline files regularly or compare very large files, this process can quickly become a real pain.

How to integrate WinMerge into WinSCP

  1. Launch WinSCP and login to an FTP site. Like most of WinSCP's features, you have to be logged in to see its main user interface.
  2. Click Options > Preferences in the WinSCP menu.
  3. In the left pane of the Preferences dialogue box, click Commands.
  4. Click the Add button.
  5. For the description field, simply enter WinMerge. This is what will appear in the WinSCP toolbar so keep it short.
  6. In the custom command field, enter one of the following depending on your version of Windows:
    • 32-bit Windows: "C:\Program Files (x86)\WinMerge\WinMergeU.exe" /dr "!@:!/" "!^!" "!"
    • 64-bit Windows: "C:\Program Files\WinMerge\WinMergeU.exe" /dr "!@:!/" "!^!" "!"
  7. Make sure the Local command radio button is selected and Apply to directories is checked. All the other checkboxes should be unchecked.
  8. You can optionally assign a keyboard shortcut.
  9. Click OK and then OK again.

Next, make the Custom Command Bar visible:

  1. Right click on any of icons in the toolbar.
  2. Select Custom Command Buttons.
Screenshot of WinMerge \

Screenshot of adding WinMerge to WinSCP

Now you can compare your online and offline text source code using the new WinMerge button in the toolbar:

Screenshot of WinSCP with new WinMerge button

As you may have noticed, I use this technique to create additional useful toolbar command to test my PHP code for syntax errors. You can do this with almost any tool that accepts command line parameters.

A few notes

First, you may notice that the WinMerge button is greyed out at times. This will happen because WinMerge doesn't know what you want to compare until you have selected a file on both the local and remove sides.

You can use this to compare multiple files at the same time. WinSCP will popup a WinMerge window for each pair to be compared. Note however that WinSCP will occasionally get mixed up and start comparing the wrong pair of files together. In that case, you will need to revert back to doing comparisons one file at a time.

Finally, a productivity tip: To make using WinMerge a little more convenient, you can also add the following command line switches just before the "/dr" so that it will end up looking like "/e /x /u /dr". The rest of the command line should remain the same.

  • /e : Enables you to close WinMerge with a single Esc key press.
  • /x : Closes WinMerge (after displaying an information dialog) when you start a comparison of identical files.
  • /u : Prevents WinMerge from adding either path (left or right) to the Most Recently Used (MRU) list.

WinMerge has many other command line switches. See the WinMerge documentation for more information.

Best regards,

Michael Milette