The idea of the “Integrated Development Experience” is a tool that brings all the systems a developer needs to develop their application into a single place. Coding, debugging, publishing, profiling… these are all tools that Visual Studio brings to our developers. Just as a general contractor doesn’t solve every problem with a hammer, however, we’re aware that Visual Studio isn’t the only tool in the developer toolkit.
One pain point we’ve been hearing about more and more is one that comes up when switching from one tool to another. Specifically, when you arrive at your other tool if you’ve been using Visual Studio without saving your code, that code shown in your other tool may be out of date. Then, when you edit the code in the other tool, your code is out of sync and it’s an ordeal trying to put everything back together.
Starting with 17.2 Preview 1, the new autosave feature will help with this. Use Visual Studio Search (Ctrl+Q) and look for “autosave”. That will take you to the Environment\Documents page in Tools\Options.
If “Automatically save files when Visual Studio is in the background” is checked, any time Visual Studio loses focus, usually as you change to another application in Windows, VS will attempt to save every dirty document in the IDE. This will include project files, solution files and even miscellaneous files that aren’t part of the project or solution. If saving a file fails for any reason (for instance, the file is read-only on disc), Visual Studio will keep your changes in the editor and simply leave the file dirty. The intent is that when you switch to another tool, after a moment, all your changes in VS will be committed to disk. While most developers will benefit from this, code files on slower disks or on remote servers will make a lot more save operations, and developers should keep that fact in mind when enabling autosave.
It’s worth mentioning that folks who are taking advantage of the “Code Cleanup on Save” feature from 17.1 will find that autosave does not trigger a Code Cleanup. We felt that it would be somewhat disruptive if it happened too often. Code Cleanup on Save will only trigger when you explicitly save the file, either through a command like Ctrl+S or implicitly as part of a build.
What do you think?
We’ve had suggestions in the past that some developers would like an even more aggressive autosave mechanism. Some developers would like Visual Studio to commit their changes to disk when Visual Studio goes idle after a set amount of time has passed. Another suggestion is to save when switching documents. If you’re the kind of developer who would find that useful, we’d love to hear from you. You can join the conversation here.
Please let us know how this feature works for you. Are you using it? Is it being too aggressive or not aggressive enough? How could we improve it? Please let us know your thoughts. We read all the suggestions provided on Developer Community as well as the comments on this blog post.
A good2have feature if that’s your style. My style, however, is smashing that Ctrl+S like it owes me money, whether I’m in Word, Notepad or VS/VS Code or Photoshop, and I’m ok staying with that 🙂
Am keen to try for a hot reload scenario (external tooling). One thing I've noticed is that it doesn't behave the same as Ctrl+Shift+S in that extensions don't execute. I have the Whitespace Visualizer extension installed, which strips unnecessary whitespace when saving. It works fine with Ctrl+Shift+S, but not with this feature.
Also, I'm very doubtful that I will want this feature on for all solutions in the long term as it will probably cause me...
Thanks for the feedback. Would you mind suggesting that here? I'd love to capture this suggestion.
The way Autosave is designed is that extensions need to opt into saves invoked via autosave. We were actively concerned that if extensions were being too aggressive here, it might result in some very uncomfortable situations, particularly if we extend autosave to act on a timer or on idle. Right now, we're finalizing a few pieces of this story, so...
I downloaded Visual Studio 2022 about 2 months ago, and have been writing code since downloading the software. I have noticed something that rather bothers me somewhat. In previous versions of Visual Studio, when I successfully compiled a project, it automatically generated an application (.exe) file. In Visual Studio 2022, I have noticed that the application (.exe) file is no longer being generated. Am I missing something in the software setup or something? Is there...
Adding a controversial feature like autosave, but then you see there are critical issues like https://developercommunity.visualstudio.com/t/1593340 causing people to be unable to use 2022 at all, that haven’t had an update in 4 months.
Priorities?
Priorities? They have it. Probably, inverted.
Bonjour,
Je viens de faire la mise à jour et je suis toujours en 17.1.2. Je n’ai pas l’option.
The feature is available in 17.2 preview 1 (17.2.1). It looks like you’re on 17.1.2, so you’ll need to update to the newest preview.
I'm with many others here in that I won't be using this feature as it causes more problems to me than it solves. Even when using source control I often make changes to files that I may or may not want to keep and it would be bad if I suddenly got a chat or voice call from my boss, or perhaps an Outlook notification about an upcoming meeting in the middle of my VS...
Yup.. Most of the time, even with git or version control, closing and reopening the file is much faster, when I think I messed during the last five minutes. Auto saving (into the real file) is an inconvenience, not a convenience. I am glad to hear that it's opt in feature, not the default feature, as in other IDEs. As for the fear of crashing / BSOD, the way Microsoft Word and Excel handled it...
> The only real use case I can see is if somebody types in some code and then switches to the command line to do something
One example is committing to a VCS from the command line. I have more than once forgotten to save my last change before switching to the command line to commit. This saves me the hassle of fixing that after the fact.
One of the other use cases we've heard from folks is when they prefer VS Code for editing some file types and VS for others. VS Code already has an autosave feature, so folks will edit over there for some file types, then jump to VS. VS Code would autosave as soon as you switch to VS. But trying to go the other way didn't work.
The VCS solution is absolutely another one, and there...
Off-topic: When did “Integrated Development Environment” get rechristened to “* Experience”?
Hmmm… apparently it get rechristened to a typo. I’m somewhat amused that I didn’t catch that. Yes, it should be an integrated development environment. No idea where Experience came from.
Probably, when woke millenials took over MS. In any case, VS is suffering what I call “dead by features”. In a year, they won’t remember all these shenanigans they are happily adding now.
Enabling this would only change where I end up being gotcha-ed; but without the easy ability to get back to the prior state. On the plus side I wouldn't end up forgetting to include some last minute comments/whitespace cleanup when committing code via my external git client. On the down side, there are also cases where I find myself deciding that whatever code I spent the last 10 minutes typing is experimental/risky enough,...
This is a great feature for those that need it. It's also amazing to know that the VS Team recognizes that not everyone operates the same way and features like this should be optional, not forced.
I think the whole "create a ~$ prepended file that has constantly saved 'dirty data' that if something happens and the file is reloaded without a proper save/discard asks if you want to resume from your...
Hi Jason! I’m Denizhan, PM on Visual Studio responsible for search and navigation.
I’m interested in the replace situation outlined above. If some text is selected and you enter ctrl + h, the replace box should only replace text in the selected area. Can you tell me more about when this is not the case?
Hey Denizhan. I just got burned a few times on the whole thing I was talking about. Every single one of the VS bug reports have been closed. Most "duplicate moved to" and moved to one that is closed. I went ahead and recorded a gif of what goes on and why it's so damned annoying.
Find+Replace keeps switching to "Current Document" even if text selected
It's pretty easy to find in developercommunity.visualstudio.com. Here's two I'm familiar with.
https://developercommunity.visualstudio.com/t/It-is-impossible-to-search-on-selection/1512668
https://developercommunity.visualstudio.com/t/Find-and-Replace-with-Selection-Bug-Vis/1549735
There's been a few fixes, but it seems to creep back up at random times. I'm just having to be extra careful. In most cases when I experience it I'm not in a position to stop the work I'm doing to attempt to submit a report(which likely I wouldn't be able to reproduce since it's so random). For...
Theoretically a nice idea to not forget saving.
The real world is different from that: When I work with a document I don't want that it overwrites my existing file until I tell it to do so. Sometimes I test something and in the end decide, that it's not so good than the old version, so if Undo goes not far enough into the past, I can throw it away and reload my old file. Which...
you should get some vcs
Of course a possible way to go, but I really don’t like VCS tools.
And I do not want to setup a VCS project each time I work with a single file I opened in VS. An autosave destroys the original file in that case (or I switch it off, then the function is also useles…).
We know that not everyone wants Autosave. That’s why the feature is *NOT* enabled by default and as far as I’m concerned, it feels like an option that folks should opt INTO. So, if it’s not for you, I completely get it. However, there are many folks who have requested this and I’m happy to finally make it available.
This is a very welcome feature. I flip between VS Code and VS2022 all day and often forget to save in VS. VS Code can save as you type, which should also be an option here in my opinion.
VS Code provides options to save on a time interval, on loss of focus and… I think there’s a third option. We’re investigating more of those options for VS as well. There’s a link to DeveloperCommunity above (and I just put it here too) to upvote other types of Autosave. Please head over there and lend your votes and voice. 🙂