Right click on another file or an editor tab. Click Diff & Merge Select file to compare. Now, right click on the second file and choose "Compare with Selected".īoom! You've got a beautiful side-by-side comparison of the two files. How to use Right click on a file 1 in explorer panel or on an editor tab. If you multi-select (Ctrl+Left-Click on Windows) both files (file1.csv, file2.csv) in the VS Code (File) Explorer window, then select Compare Selected from the right-click menu in the (File)Explorer window, a diff window will open with the comparison you desire. From the file explorer, right click on the first file to compare. Now, for something completely different! Is the shell command line not your cup of tea? Visual Studio Code to the rescue! Code has a built-in diffing feature. Isn't that better? You could very quickly see the differences in giant files. suppress-common-lines (sadly there is no shorthand) prevents the output from displaying any lines that are identical. That's all well and good, but can you imagine scrolling through a 5000 line comparison looking for a few differences? What a pain.Ī new flag □ to the rescue! diff sample1.json sample2.json -y -suppress-common-lines. Compare any two commits by clicking on a commit, and then CTRL/CMD clicking on another commit. Click on any HTTP/HTTPS url in the commit body to open it in your default web browser. Copy the path of any file that was affected in the commit to the clipboard. Wow! That's a huge improvement! Between the files, the | is an indicator that the lines are different. Open the current version of any file that was affected in the commit. This does the same comparison but puts the results side by side. diff sample1.json sample2.json -y (the -y is shorthand for -side-by-side). Let's make it a bit simpler by adding another flag to the command. It's great information, if not a bit hard to read. That's indicating that the first file has a 14th line that the second file does not have. 7,9c7,9 means there are differences in lines 7 through 9 and the subsequent lines display the differences. The symbols point to the relevant file: left (first file) and right (second file). You can compare (diff) text selections within a file, across different files, or to the clipboard. 4c4 means there is a difference or change on line 4 of each file. You'll find a slew of options to improve the default experience.įor the default comparison, just type diff name-of-file1 name-of-file2 and you'll get a result like this:īasically, you're seeing a summary of differences between lines. Have you ever needed to easily tell the difference between two files? diff on the command line to the rescue!įirst, don't forget to examine the docs by doing man diff from the command line.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |