I hate this warning so much that I forked Neovim and ripped the feature out.

You changed branches or performed some other Git operation that updated the file you have open, and that means a different modification time. Vim compares it to that of when it was last read and gives you this message if they differ:

WARNING: The file has been changed since reading it!!!
Do you really want to write to it (y/n)?

Perhaps you temporarily switched to another branch. You had to check something on master briefly and didn't want to use a Git worktree. After two git checkouts, and despite your files being exactly the same, Vim is tipped off that they changed. So then you get to fight through this warning for each file you have open.

This sucks especially in CLI Vim, which is what I use, because it bumps up the entire console output of Vim until you respond to the prompt. Usually Vim doesn't then refresh properly, requiring you to force an unnatural act of a full redraw.

The fork, sans-warning

My fork of Neovim adds an option called overwritewarning and lives here:


This is the description of this new option:

:help ow

 *'overwritewarning'* *'ow'*
         *'nooverwritewarning'* *'noow'*
'overwritewarning' 'ow'   boolean (default on)
  When writing a file, Vim ensures its modified time hasn't
  changed since the last read. Specifies whether the user is prompted
  for confirmation if this time differs with "WARNING: The file has
been changed since reading it!!!"

I use Neovim pretty much daily so I do plan on continuous rebasing on the main repo.

Here's how to build and install it alongside of stock/system Neovim.

FAIR WARNING: This invites accidental overwrites with the thinking that version control (Git) is more than capable of handling these scenarios. It's now your responsiblity to manage when you are overwriting a change, and if you are unprepared this may get you in trouble. I suggest only doing this if you feel that the warning gets in your way more than it saves you from yourself. If you're not already, you should now always review staged changes with a git diff --staged and to know when you need to refresh your Vim buffer manually (:e). Otherwise removing this warning will definitely cause you surprises.

If you are not comfortable with that, don't do this. The original feature was written for a reason.

  1. Check out the fork:

    git checkout https://github.com/mcnelson/neovim.git
  2. Install Libtool via your package manager. I.e. on Fedora: dnf install libtool.

  3. Follow the instructions on the Neovim Wiki Page. This method installs Neovim stand-alone at ~/neovim so it won't interfere with your system Neovim instance. That way, if the feature is ever merged to the main project, you can simply remove ~/neovim and update your main version.

    rm -r build
    make distclean
    make install
  4. Add the binary to your PATH in your Bash profile -- .bashrc or .profile. This serves as the switch between custom and stock Neovim.

    export PATH="$HOME/neovim/bin:$PATH"
  5. Launch nvim and open your ~/.config/nvim/init.vim. Add:

    set noow # No overwrite warning
  6. Source your config file to establish the new setting.

    source %
  7. Test that it's working:

    nvim /tmp/foo

    With Neovim open, separately run:

    touch /tmp/foo

    Back to Neovim, and run :w. It should now quietly overwrite the file.

Maybe I'll try to merge this back to the main Neovim project, but it's kind of a workaround. A much better solution would be a quick diff of the original and new buffer. Then we'd only see the warning if there are actual changes.

Until then, I hope this alleviates some frustration.

More blog posts