I have this mapping:

nnoremap <leader>755 :silent !chmod 755 %<CR>

When I trigger the mapping in a buffer that displays a file with a permission other than 755, it prints the message

W16 "Warning: Mode of file "..." has changed since editing started" 
See ":help W16" for more info
[O]k, (L)oad File

In order to proceed with editing, I have to acknowledge this message. Is there a way to prevent this message in my mapping.

1 Answer 1


You can use "autoread". From :help autoread

                 *'autoread'* *'ar'* *'noautoread'* *'noar'*
'autoread' 'ar'     boolean (default off)
            global or local to buffer |global-local|
            {not in Vi}
    When a file has been detected to have been changed outside of Vim and
    it has not been changed inside of Vim, automatically read it again.
    When the file has been deleted this is not done.  |timestamp|
    If this option has a local value, use this command to switch back to
    using the global value: >
        :set autoread<

I've used this for when a file has been edited outside of vim. I just tested it, and it also works for when a file's mode has been changed. It's a slightly different use-case, but hey, it works!

You might want to add :w to the beginning, to guarantee that it will actually reload. Otherwise, you'll get different errors.

I did run into a weird problem when I tested it. It might just be my terminal+window manager setup, so you may or may not have this too. Vim would refuse to update after doing this. To fix this, you can add <C-l> to the end of your mapping.

Putting this all together, the remapping should look like this:

nnoremap <leader>755 :w | silent !chmod 755 %<CR><C-l>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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