The reason for this problem is probably because VS code sorts the imported packages and formats the codes first when saving the file.
You should turn off these features, then the time to save the file will be greatly reduced.
Add the following configuration to the settings.json to turn off these two functions:
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.organizeImports": false
}
Answer from JialeDu on Stack OverflowIve used VS code for the last 6 years of programming. But recently its gotten so slow. It doesnt find my imports, doesnt format on save, it just lags everything besides the stupid description popups when you hover unimportant elements..
So whats my alternative? Is there some settings I can change to help me out or should i abandon ship and use another IDE?
Videos
And the project is new.
vue official plugin kinda just suck now for some reason.
Trust the workspace folder you're working on explicitly (no parent folders). It might be taking a long time to check if the folder you're executing is trusted for each filesystem operation. To do this:
F1 > Workspaces: Manage Workspace Trust > Add Folder > add workspace folder (not a parent!)
I have encountered the same issue today (Visual Studio Code 1.52.1) while working on CSV and HTML files. Saving a file took like 1 or 2 minutes to finish. I have resolved it by updating VS Code to 1.53.1 version and disabling all extensions.
I have re-enabled extensions one by one to see if the issue came from a specific extension. It still works so far.
In vscode, i tried to disable all the extensions that i installed previously, i disabled them one by one, after each disable, i test by changing the code then saving, yet the problem persists, until all the extensions are off.
Then i remembered there are some other built-in extensions. I opened the extensions, then pressed on the three dots at the top right of the left side bar, then i chose Show running extensions, the Running extensions will open and you will find among them git. I noticed that git in unresponsive and had a huge number beside it like 4000+ms which is substantially greater than all the other extensions.
Notice that i am using git version 2.34.1. Also the git extension is ok and responsive during Rust development.
So i updated git to the latest version which is 2.37.1 using these commands:
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
Now i restarted vscode and the git extension is responsive and working properly. Also the saving is fast and everything in fine.
The problem was due to unresponsive git extension only in C++ development as far as i know. So update git to the latest version.
Update:
I think the problem still exists even after i updated git to the latest version. The delay still only happens with C++ development. The problem is solved once i initialized git in my working directory using git init. When i restart vscode, everything works fine. Here is a screenshot of the Running extensions when the problem exists (Notice the first git extension):

Update:
I think i knew where the problem is. The directory of my C++ project is /home/user/Projects/cpp/testing_1, in cpp/ directory i put all my C++ projects such as testing_1/, testing_2/ and so on. I initialized git in cpp/ dir before which is the parent dir of all my projects. When i deleted that .git dir in cpp/ the git extension in responsive and working fine, even when i am not initializing git in my working project such as testing_1/. I think not initializing git in the parent dir of your project solved the problem. I will see where that goes.
Not exactly a fix, but I ended up uninstalling the Microsoft C/C++ extension and installing the clangd extension. Now, not only is the formatting instant, but also the code completion suggestions and the go-to-definitions are way better and faster.