This plugin adjusts the default file-changed prompt.
- You probably don't need this plugin it you're happy with
autoread.- If you're running Vim,
autoreadis not enabled by default.- Run
set autoreadand be happy.
- Run
- If you're running Neovim, you're all set.
- If you're running Vim,
But if you want a few quality of life improvements, sure, maybe check out this plugin!
For
vim-gtkand MacVim, it makes the prompt a little less wordy.- For MacVim specifically, it hints at how to use the somewhat confusing UX (there are two buttons highlighted in blue — so what does pressing <Enter> do??)
It adds additional alerts where (Neo)Vim is otherwise silent.
For example, when
autoreadis enabled, if a buffer is unchanged but its external file changes, Vim loads the changes and prints a message.But in Neovim, nothing is printed.
This plugin restores that message.
By default, Vim prompts you if a buffer you're working on was changed by an external program.
Here's a look at the default prompt on macOS in MacVim:
If you're not familiar with macOS dialog wiring:
- The button with the blue background is picked
when you press
<Enter>. - The button with the blue border is picked when
you press
<Space>. - You can move the selected button with
<Tab>.- Regardless of the selected button,
<Enter>will always pick the "OK" button.
- Regardless of the selected button,
- There are no accelerators defined (e.g., nothing like
an
<Alt-L>accelerator you might find on Linux).
This plugin changes the prompt thusly:
You'll see that the prompt text is a little less wordy than the
default, and there's a helpful little hint added to remind you
how <Enter> and <Tab>/<Space> work on macOS.
- And if you've read
:help W11once, you probably don't need to be reminded of it every time.
In the other Vims — Linux GVim, terminal vim, and terminal
nvim — you'll see similar changes to the prompt.
Vim identifies at least six different types of changes:
- The file on disk was deleted while a buffer is open.
- The file timestamp was changed.
- The file permissions were changed.
- The file contents were changed, but the buffer has
not been modified (
:help modified). - The file contents were changed and the buffer has local modifications.
- The file on disk was created after a buffer with
that path was opened.
- This is actually a different prompt altogether
that is not scriptable (
:help W13).
- This is actually a different prompt altogether
that is not scriptable (
If Vim notices that a file is deleted while a buffer is open,
it alerts, E211: File "{filepath}" no longer available,
but it doesn't prompt.
- If the file is created again, Vim doesn't announce it,
unless the local buffer has changes.
- So this plugin emits a message when the deleted file has since been undeleted.
If Vim notices that only the timestamp has changed, it won't alert you. It will ignore the event and move on.
- This plugin will instead print a short message to bleep you, because what the hay (but it won't prompt you).
- For you rebasers out there, this event occurs frequently when you rebase history.
If Vim notices that the permissions have changed, the Vim default is to always prompt you.
- This plugin will not prompt you when permissions change. [Although maybe it should, or at least if the file is no longer writable or readable by the user. But that's a rare use case we're not gonna worry about. But please open an Issue if this impacts you negatively.]
If Vim notices external changes and the local buffer has not been modified, it'll print a message like you'd normally see when you edit a file, e.g.,:
"file" 3L, 9B
Interestingly, in Neovim, nothing is messaged. Neovim silently loads changes.
This plugin prints an alert like Vim does, but telling you explicitly what happened (unlike, e.g.,
"file" 3L, 9B), and colorfully, too (imagine the following with a yellow background, for example), e.g.,:File changed! 📠 /path/to/file
Finally, when conflicts are detected, this plugin will prompt
you, just like Vim or Neovim does, regardless of autoread,
albeit with the dialog changes described earlier.
Relevant Vim documentation for the endlessly curious:
Vim Tip: File no longer available - mark buffer modified, by Ewfalor, 2008:
https://vim.fandom.com/wiki/File_no_longer_available_-_mark_buffer_modified
- This tip provides a simple
FileChangedShellhander that was the basis for this project's file-changed handler.
- This tip provides a simple
I originally made this plugin because I wanted to be prompted
when external changes happened, even if there was no conflict,
so that I could choose what to do. But I wanted the default
choices to be opposite Vim's — e.g., if set noautoread and
Vim shows the conflict prompt, the default is to Keep Changes,
but I wanted the default to be Load File.
- So when no conflicts, I wanted to be able to hit <Enter> to load changes.
- But when there were conflicts, I wanted to be able to hit <Enter> to ignore changes.
Nowadays, I prefer autoload behavior — not to be prompted
when there are external changes but not conflicts, but to just
load changes — but I also like the additional messages provided
by this plugin.
interuptless.vim— Makes vim interrupt you lessvim-autoread— Have Vim automatically reload a file that has changed externally
Take advantage of Vim's packages feature (:h packages)
and install under ~/.vim/pack, e.g.,:
mkdir -p ~/.vim/pack/embrace-vim/start cd ~/.vim/pack/embrace-vim/start git clone https://github.com/embrace-vim/vim-better-file-changed-prompt.git " Build help tags vim -u NONE -c "helptags vim-better-file-changed-prompt/doc" -c q
- Alternatively, install under
~/.vim/pack/emrace-vim/optand call:packadd vim-better-file-changed-promptto load the plugin on-demand.
For more installation tips — including how to easily keep the
plugin up-to-date — please see INSTALL.md.
The embrace-vim logo by @landonb contains
coffee cup with straw by farra nugraha from Noun Project
(CC BY 3.0).

