When I'm using nvim with firenvim, I use it to only edit the 1 text box in the browser. I typically have to need to open another file. Even with strict security policies, I'd like to disable nvim's ability to read from and write to other files besides the one in the current buffer. This is to be used in conjunction with some other settings and features for firenvim in order to lock down nvim inside the browser for security.

Is there a way to block nvim from opening another file?

1 Answer 1


Not sure if it can close all the holes, but I'd probably start with something like:

augroup test | au!
    autocmd BufLeave * throw 'Not allowed!'
augroup end

No doubt, you also should at least have :set secure.

  • Wouldn't the autocmd effectively disallow any exiting when used? I don't want to open another file but still want to be able to quit the current buffer. Dec 24, 2020 at 10:22
  • 1
    @JohnZhau As usual, read :h BufLeave.
    – Matt
    Dec 24, 2020 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.