Last updated: Apr 6, 2024
Reading time·3 min
To highlight the modified lines in Visual Studio Code:
git init
command.git init
If you need to open VS Code in the current directory, use the following command.
code .
Make changes to a specific file.
You can stage and commit the changes with the following commands.
git add . git commit -m 'your commit message'
In order to highlight the modified lines in VS Code, you have to use version control (Git).
Notice that there are left borders with multiple different colors depending on the modification.
You can view the exact changes that were made to the file by:
Clicking on Source Control in the left sidebar.
Selecting the specific file.
You can also focus the Source Control view with a keyboard shortcut:
Ctrl
+ Shift
+ G
(works on Windows, macOS and Linux).Once you select the file a side-by-side view opens where you can view the changes you've made to the file since the last commit.
Note that if you stage the file, the highlighting of the modified lines disappears.
You can either stage a file with git add .
or by clicking on the +
icon next
to the file's name in the Source Control pane on the left.
Here is a short clip that demonstrates how this works.
You can also stage and unstage files using the terminal.
git add . git status git restore --staged .
Note that if the file is staged, you won't see the highlighting of the modified lines.
If you still aren't able to see the modified lines after unstaging your files, try to restart VS Code.
I've also written a detailed guide on the
meaning of the U
and M
file markers
in the left sidebar in VS Code when working with Git.
You can learn more about the related topics by checking out the following tutorials: