Newbie question: how to turn off file watching?

It seems that by default in neovim, if a file changes on disk, neovim reloads the file from disk. This is different from vim, which requires you to do something like :e! to reload the file.

Though I can see why one might sometimes want the automatic file watching behavior, I don’t want it by default. (For me, it’s dangerous.) How can I turn this off?

I think this is probably common question, but I haven’t found the answer. I searched for “watch” and “reload” in the help system, in the FAQ, in the online version of the help system (both via :help <term> and by simply searching in the main help file), in vim.stackexchange with the [nvim] tag, and I read through nvim-from-vim again. The answer is probably somewhere in one of these sources, but I have been unsuccessful in finding it. (:help watch does bring up a location in lua.txt that explains how to write a file-watcher.) Some things are difficult to search for effectively.

I’m also not sure whether this is the place to ask this kind of very basic question. Please let me if I should be asking somewhere else.

That should be :set noautoread.

1 Like

Note that if you modified the buffer while another version was written somewhere else, autoread asks oyu if you want to reload, so there are some safeguards too.

I want to be asked. :set noautoread seems to force that. With autoread set, it doesn’t ask, but just updates the buffer. I can undo it, but I have to notice that it’s changed.

I now see that I ought to study the *nvim-defaults* section of the help files that is linked from “Strong defaults” on the main Neovim page. I wasn’t aware of that section until later.