0

When working with a file that is regularly changing externally, a popup warning dialog is opened, asking whether to keep buffer contents (the default) or load the updated file into the buffer:

enter image description here

Is it possible to change the default button to Load File instead of OK, so a single press on Enter reloads the file?

I am aware of the autoread option, but I still want to be able to control the update.

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
ysap
  • 2,620
  • 12
  • 50
  • 74
  • Many will argue that the default is so for a reason, namely to avoid accidentally overriding the edited contents with an inadvertent press of Enter. – Ingo Karkat Mar 21 '14 at 15:15
  • @IngoKarkat - Obviously, but I want to change it. – ysap Mar 21 '14 at 15:58

1 Answers1

1

To do that, you'd have to modify Vim's source code and compile your own version.

Alternatively, you can hook into the FileChangedShell event and implement your own emulation of the original dialog (with confirm()); :help FileChangedShell has all the details on that.

Ingo Karkat
  • 22,638
  • 2
  • 45
  • 58
  • Thanks. Vim is just amazing. Every time a semi-advanced question is answered, it opens a Pandora's box... Looking at the suggested help page, there seems to be a whole new world of those events... – ysap Mar 21 '14 at 15:39
  • So I wanted to test this thing. Defiend a new group `:aug my_test_group`. Then, defined an autocmd: `au my_test_group FileChangedShell * confirm("TEST","&Y\n&N",2,"W")`. Changed the buffered file externally. When returned focus to gVim, I get an error: `E492: Not an editor command: confirm(...`. I cannot run the `confirm()` command from the `:` command prompt either. – ysap Mar 21 '14 at 15:43
  • OK, got it. I can do `let a=confirm(...` – ysap Mar 21 '14 at 15:46
  • Please see my follow up question here: http://superuser.com/q/731979/45564 . Thanks. – ysap Mar 21 '14 at 19:20