ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.meziantou.net/comparing-files-using-visual-studio-code.htm |
| Last Crawled | 2026-04-09 03:36:48 (10 hours ago) |
| First Indexed | 2019-06-13 07:27:57 (6 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Comparing files using Visual Studio Code - Meziantou's blog |
| Meta Description | Learn how to compare files in Visual Studio Code using the UI or command line, and how to configure VS Code as your Git diff tool. |
| Meta Canonical | null |
| Boilerpipe Text | In the previous post, I showed you how to
use Visual Studio to compare 2 files
. Visual Studio Code is another great option, and like any capable IDE, it includes a powerful built-in diff tool. Like Visual Studio, you can use it to compare two versions of the same file when using source control, or compare any two files from your file system.
This post covers multiple ways to use the Visual Studio Code diff tool.
#
Comparing files using the User Interface
Open the 2 files in Visual Studio Code
Right-click on one file and click "Select for compare"
Right-click on the other file and click "Compare file file1 with file2"
You should see the result:
#
Comparing files using the command line
Using Visual Studio Code
Shell
code --diff file1.cs file2.cs
Or, using the full path if code is not in the
PATH
:
Shell
"
%LOCALAPPDATA%
\Programs\Microsoft VS Code\code.exe" --diff file1.cs file2.cs
Using Visual Studio Code Insiders
Shell
"
%LOCALAPPDATA%
\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" --diff file1.cs file2.cs
#
Using Visual Studio Code as a git difftool
git difftool
is a Git command that allows you to compare and edit files between revisions using common diff tools. You can use any editor that supports diff such as VS Code. Open a command prompt and use the following commands:
From CMD (Windows)
Shell
git config --global diff.tool vscode
git config --global difftool.vscode.
cmd
"code --wait --diff \"$LOCAL\" \"$REMOTE\""
From PowerShell (Windows or Linux)
PowerShell
git config
--global
diff.tool vscode
git config
--global
difftool.vscode.cmd
"code --wait --diff "
"`$LOCAL"
" "
"`$REMOTE"
""
From Bash (Linux)
PowerShell
git config
--global
diff.tool vscode
git config
--global
difftool.vscode.cmd
'code --wait --diff "$LOCAL" "$REMOTE"'
Manually, open
~/.gitconfig
or
%USERPROFILE%\.gitconfig
in a text editor and add the following content:
INI
[diff]
tool
= vscode
[difftool "vscode"]
cmd
= code --wait --diff \
"$LOCAL\" \"$REMOTE\"
You can verify the configuration by running
git config --global --list
.
You can also configure Visual Studio Code as your Git editor:
Shell
git config --global core.editor "code --wait"
Do you have a question or a suggestion about this post?
Contact me! |
| Markdown | [Meziantou's blogBlog about Microsoft technologies (.NET, ASP.NET Core, Blazor, EF Core, WPF, TypeScript, etc.)](https://www.meziantou.net/)
- [Home](https://www.meziantou.net/)
- [Projects](https://www.meziantou.net/projects.htm)
- [Talks](https://www.meziantou.net/speaking.htm)
- [Archives](https://www.meziantou.net/archives.htm)
- [About](https://www.meziantou.net/about.htm)
- [Contact](https://www.meziantou.net/contact.htm)
# Comparing files using Visual Studio Code
03/19/2018
- Gérald Barré
- [Tips](https://www.meziantou.net/archives-categories-tips.htm)
In the previous post, I showed you how to [use Visual Studio to compare 2 files](https://www.meziantou.net/comparing-files-using-visual-studio.htm "Comparing files using Visual Studio"). Visual Studio Code is another great option, and like any capable IDE, it includes a powerful built-in diff tool. Like Visual Studio, you can use it to compare two versions of the same file when using source control, or compare any two files from your file system.
This post covers multiple ways to use the Visual Studio Code diff tool.
Table Of Contents
- [Comparing files using the User Interface](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#comparing-files-usin)
- [Comparing files using the command line](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#comparing-files-usin-7cf2ec)
- [Using Visual Studio Code as a git difftool](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#using-visual-studio-7cf2ec)
## [\#](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#comparing-files-usin)Comparing files using the User Interface
1. Open the 2 files in Visual Studio Code
2. Right-click on one file and click "Select for compare"

3. Right-click on the other file and click "Compare file file1 with file2"

You should see the result:

Note
The right panel is editable, which lets you edit the new version of the document while viewing the live diff.
## [\#](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#comparing-files-usin-7cf2ec)Comparing files using the command line
- Using Visual Studio Code
Shell
copy
```
code --diff file1.cs file2.cs
```
Or, using the full path if code is not in the `PATH`:
Shell
copy
```
"%LOCALAPPDATA%\Programs\Microsoft VS Code\code.exe" --diff file1.cs file2.cs
```
- Using Visual Studio Code Insiders
Shell
copy
```
"%LOCALAPPDATA%\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" --diff file1.cs file2.cs
```

## [\#](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#using-visual-studio-7cf2ec)Using Visual Studio Code as a git difftool
`git difftool` is a Git command that allows you to compare and edit files between revisions using common diff tools. You can use any editor that supports diff such as VS Code. Open a command prompt and use the following commands:
- From CMD (Windows)
Shell
copy
```
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff \"$LOCAL\" \"$REMOTE\""
```
- From PowerShell (Windows or Linux)
PowerShell
copy
```
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff ""`$LOCAL"" ""`$REMOTE"""
```
- From Bash (Linux)
PowerShell
copy
```
git config --global diff.tool vscode
git config --global difftool.vscode.cmd 'code --wait --diff "$LOCAL" "$REMOTE"'
```
- Manually, open `~/.gitconfig` or `%USERPROFILE%\.gitconfig` in a text editor and add the following content:
INI
copy
```
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff \"$LOCAL\" \"$REMOTE\"
```
You can verify the configuration by running `git config --global --list`.
You can also configure Visual Studio Code as your Git editor:
Shell
copy
```
git config --global core.editor "code --wait"
```
Tip
You can now configure Visual Studio Code as your default merge tool for Git using `git config set merge.tool vscode` (requires Git 2.47)
Do you have a question or a suggestion about this post? [Contact me\!](https://www.meziantou.net/contact.htm)
Follow me:
Enjoy this blog?
- [](https://www.buymeacoffee.com/meziantou "Enjoy this blog? Consider buying me a coffee!")
- [💖 Sponsor on GitHub](https://github.com/sponsors/meziantou "Enjoy this blog? Consider sponsoring me on GitHub!")

# Gérald Barré
aka. meziantou
[](https://goto.meziantou.net/microsoft-mvp)
# Recent posts
- [Accessing files from the action repository in a GitHub Composite Action](https://www.meziantou.net/accessing-files-from-the-action-repository-in-a-github-composite-action.htm)
- [URL Pattern Matching in .NET](https://www.meziantou.net/url-pattern-matching-in-dotnet.htm)
- [Speed Up .NET CI with Test Sharding](https://www.meziantou.net/split-dotnet-test-projects-into-shards-with-meziantou-shardedtest.htm)
- [Implementing RFC-compliant HTTP caching for HttpClient in .NET](https://www.meziantou.net/implementing-rfc-compliant-http-caching-for-httpclient-in-dotnet.htm)
- [Visualize GitHub Actions runs with Meziantou.GitHubActionsTracing](https://www.meziantou.net/visualize-github-actions-runs-with-meziantou-githubactionstracing.htm)
# Links
- [Dev Tool List](https://www.meziantou.net/setting-up-my-development-machine.htm)
- [Async/await resources](https://www.meziantou.net/links-async-await-csharp.htm)
- [.NET Multithreading resources](https://www.meziantou.net/links-about-multithreading-in-dotnet.htm)
- [Visual Studio tips](https://www.meziantou.net/archives-series-visual-studio-tips-and-tricks.htm)
- [Online tools](https://tools.meziantou.net/)
- [free-for.dev](https://free-for.dev/)
Copyright © 2026 Gérald Barré - Use of this site constitutes acceptance of our [Terms of use](https://www.meziantou.net/terms-of-use.htm) and [Privacy policy](https://www.meziantou.net/privacy-policy.htm).
[](https://www.buymeacoffee.com/meziantou "Enjoy this blog? Consider buying me a coffee!") |
| Readable Markdown | In the previous post, I showed you how to [use Visual Studio to compare 2 files](https://www.meziantou.net/comparing-files-using-visual-studio.htm "Comparing files using Visual Studio"). Visual Studio Code is another great option, and like any capable IDE, it includes a powerful built-in diff tool. Like Visual Studio, you can use it to compare two versions of the same file when using source control, or compare any two files from your file system.
This post covers multiple ways to use the Visual Studio Code diff tool.
## [\#](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#comparing-files-usin)Comparing files using the User Interface
1. Open the 2 files in Visual Studio Code
2. Right-click on one file and click "Select for compare"

3. Right-click on the other file and click "Compare file file1 with file2"

You should see the result:

## [\#](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#comparing-files-usin-7cf2ec)Comparing files using the command line
- Using Visual Studio Code
Shell
```
code --diff file1.cs file2.cs
```
Or, using the full path if code is not in the `PATH`:
Shell
```
"%LOCALAPPDATA%\Programs\Microsoft VS Code\code.exe" --diff file1.cs file2.cs
```
- Using Visual Studio Code Insiders
Shell
```
"%LOCALAPPDATA%\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" --diff file1.cs file2.cs
```

## [\#](https://www.meziantou.net/comparing-files-using-visual-studio-code.htm#using-visual-studio-7cf2ec)Using Visual Studio Code as a git difftool
`git difftool` is a Git command that allows you to compare and edit files between revisions using common diff tools. You can use any editor that supports diff such as VS Code. Open a command prompt and use the following commands:
- From CMD (Windows)
Shell
```
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff \"$LOCAL\" \"$REMOTE\""
```
- From PowerShell (Windows or Linux)
PowerShell
```
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff ""`$LOCAL"" ""`$REMOTE"""
```
- From Bash (Linux)
PowerShell
```
git config --global diff.tool vscode
git config --global difftool.vscode.cmd 'code --wait --diff "$LOCAL" "$REMOTE"'
```
- Manually, open `~/.gitconfig` or `%USERPROFILE%\.gitconfig` in a text editor and add the following content:
INI
```
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff \"$LOCAL\" \"$REMOTE\"
```
You can verify the configuration by running `git config --global --list`.
You can also configure Visual Studio Code as your Git editor:
Shell
```
git config --global core.editor "code --wait"
```
Do you have a question or a suggestion about this post? [Contact me\!](https://www.meziantou.net/contact.htm) |
| Shard | 106 (laksa) |
| Root Hash | 13243292651965060106 |
| Unparsed URL | net,meziantou!www,/comparing-files-using-visual-studio-code.htm s443 |