During a OS upgrade (Linux), Vim or some part of it has been updated as well.

Now it happens that sometimes when I save a file (the file is not saved) I get this error:

E21: Cannot make changes, 'modifiable' is off

I did :help E21 and the manual says:

        {not in Vi}     *E21*
When off the buffer contents cannot be changed.  The 'fileformat' and
'fileencoding' options also can't be changed.
Can be reset with the |-M| command line argument.

It's not clear to me what it means. I use and start the editor the usual way, nothing is changed. The workflow is the same, too. I open different windows with CTLR-W N, then load and edit files there and switch between windows, etc.

I'd like to know how to disable this behavior and about side effects.

up vote 5 down vote accepted

You can use :verbose set modifiable? to find out if a plugin is setting the option. If the option has been modified by a plugin, it will show Last set from /path/to/plugin/file (in addition to showing the value).

Maybe you are using the Netrw plugin. It comes bundled with Vim and handles “editing” local directories (listing the contents, picking files to view/edit) and remote file/directory access. I know it twiddles modifiable (and some other options). There may be a bug in the version bundled with your updated Vim. You can check the version number of the active installation of Netrw with :echo g:loaded_netrwPlugin.

If the problem seems to be related to Netrw, you might try installing another released version, or maybe a development version.

This happens when you open a file that is read-only. Check the file permissions: it seems that your user doesn't have write permission on the file. Or maybe the filesystem is mounted read-only (check with df /path/to/file to see on what filesystem the file is, and use mount or cat /proc/mounts to see the mount options).

A different possibility would be a buggy decoding plugin, but then I'd expect other error messages.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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