force vim to overwrite external changes

vi, vim

Solution

Indeed, the overwrite confirmation cannot be turned off with `:w!`, and `:set autoread` doesn't help in this case, neither. What does work is instructing Vim to explicitly check for changes before the write:

:checktime | w

Problem

I use Vim 7.4 (Mac OS) to edit and run Lua scripts. I've mapped a key in my .vimrc to save the current buffer and run an external script. The key map in .vimrc: ``` map V :w!<CR> :!python "$HOME/tools/client/concli.py" --lua %<CR> ``` It works fine but every once in a while the files are 'touched' by Xcode (touch shell command). Then when I hit the mapped key vim warns me that the file has been changed externally and I have to confirm to write to it. This is quite annoying since the files are often touched. How could I force vim to overwrite external changes without prompting? I tried 'w!' without success. Thank you, Laurent

Original source

Related problems