Comparing Things in PhpStorm II

Comparing two files and observing the differences in PhpStorm

In the last article, we looked at comparing versions of a single file in PhpStorm. In this one, series of articles, we'll look at ways to compare things in the PhpStorm development platform.

MODX logo

Comparing Two Files in your Project

Suppose you have duplicated a file and renamed the original copy to somefile.old. As an aside, in PhpStorm, this process is really sweet. You just select the file in the file tree, press Ctrl-c, then select the file's parent directory and press Crtl-v. A window will pop up with the original file name. You add ".old" to the end and click "OK." Later, after editing the new version, you want to see the differences and either revert some of your changes, or save some of the new changes to the old file. You select both files in the tree with Ctrl-click, then right-click on one of them, or press Ctrl-d (D for diff) and you'll get the same window we described in the previous section. You can move changed sections either way with a single click. (Tip: the one you select first will be on the left.)

I often use this feature when I have the same file in different extras of mine. If I've updated a section of code in one file and I want to move that code, but not the whole file, to another extra I can do it with a few clicks. Notice that in this mode, you can move changes either way.

Comparing a Project File with a File Outside your Project

What if one of the files is not in your project? I have multiple MODX installs on my machine, each one in its own project. Some are backups of live sites. Suppose I want to compare the .htaccess files from the two sites. I can't use the method above because they're in different projects. No problem. I select one of the .htaccess files, press Ctrl-d, and a window pops up with the entire file tree of my drive. I just navigate to the other .htaccess file, select it, and presto, I'm in the compare window and can easily move sections that are different either way between the two files.

Coming Up

In the next article, we'll look at comparing whole directories in PhpStorm.

Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at A2 hosting. (More information in the box below.)

Comments (0)

Please login to comment.