- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:w
doesn't save unchanged file
#1282
Comments
Just tried this on vanilla vim and it saves the file regardless of it's 'dirtiness'. I recall there was a reason why we checked the dirty flag though... In any case, PRs are welcome. |
Cool. I'm happy to submit a PR. I imagine it will be fairly trivial.
I'll look at the blame first to see if there's any gotchas I should be aware of. |
https://code.visualstudio.com/updates/v1_10#_manually-trigger-save-actions Does this work for you now by any chance? |
Hm. Doesn't seem to affect |
ah ok yea I forgot we still had an isDirty check |
hmm this looks to be on vscode's side, we call save, we don't have an isDirty check for write on our side...
|
What's the current status of it? TBH I cannot recall facing it before VS Code v1.21 update, but now :w definitely does not save unchanged file, but Ctrl+S does. Found this out while live-reloading a project via UPD: Sorry, didn't read carefully enough the upstream issue. It seems such API hasn't been implemented in VS Code yet. |
Actually, it would be great temporary fix if we could use something like this in settings: "vim.otherModesKeyBindingsNonRecursive": [
{
"before": [":", "w"],
"after": [],
"commands": [{
"command": "workbench.action.files.save",
"args": []
}]
}
] |
@evenfrost Is there any way to do something like that, for example, to map :W to :w? It's not even funny how often I type :W when I mean to type :w and it slows down my workflow. In vanilla vim, I can simply remap the command, but I don't see how to map commands here. Normal mode and visual mode, yes, but :W or some such, no. |
@jhwheeler I haven't tested it, but something like that could work:
|
@evenfrost Thank you. However, it doesn't work; I still get I'm wondering if |
|
2019, same problem. I have |
Still the same issue in 2020! I want to use :w to quickly format my files with Black. The workaround I'm using is inserting an empty line, and then saving. Which calls the formatOnSave. |
Same issue with version 1.52. |
I would suggest up-voting the VS Code issue: microsoft/vscode#22040. The extension passes thru the |
Looks like this is the solution:
|
I believe Ben's comment in the linked comment is offering proposals. AFAIK, this is still an open issue against VS Code to enable extensions a |
Any update on this issue? :w used to save files for me and just stopped working, probably with the latest update of vscode (my neovim hasn't chagned lately). I've got vscode 1.60.1. |
In case people are not finding this. This solution works well in 2024 on Cursor and I guess will still work on VS Code |
Please thumbs-up 👍 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.
So sometimes I trigger my tools to run by resaving files without having changed them (typically to run tests in
guard
). In Vim:w
will cause this to happen, in VsCodeVim it presumably checks the file's dirty state before saving. Sounds logical on paper, but is a bit inconvenient for me in practise.What did you do?
:w
on unchanged file.What did you expect to happen?
My file watcher tools to run.
What happened instead?
Nothing. (File was not updated)
Technical details:
The text was updated successfully, but these errors were encountered: