Vim: `:w` doesn't save unchanged file

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:

  • VSCode Version: 0.9.0
  • VsCodeVim Version: 0.5.2
  • OS: OSX Sierra

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 30
  • Comments: 20 (11 by maintainers)

Most upvoted comments

"vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": [":", "w"],
            "commands": [
                "workbench.action.files.save",
            ]
        }
    ]

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": []
    }]
  }
]

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.

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.

2019, same problem. I have Format On Save enabled, but doing :w does not format it while Command+S does

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 force save – I haven’t taken a look at the VS Code extension API lately.

@jhwheeler I haven’t tested it, but something like that could work:

  "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": [":", "W"],
            "commands": [
                ":w"
            ]
        }
    ]

What’s the current status of it? TBH I cannot recall facing it before VS Code v1.21 update, but now <kbd>:w</kbd> definitely does not save unchanged file, but <kbd>Ctrl</kbd>+<kbd>S</kbd> does. Found this out while live-reloading a project via nodemon.

UPD: Sorry, didn’t read carefully enough the upstream issue. It seems such API hasn’t been implemented in VS Code yet.