vim "modifiable" is off
Asked Answered
I

7

188

I am trying to create a new file with NERDTree. I hit the a key to create a new file and I get the message:

E21: Cannot make changes, 'Modifiable' is off

I'm using MacVim with Janus (almost out of the box).

Interclavicle answered 21/4, 2011 at 14:30 Comment(2)
fyi: m and then a is to add a new file in NERDTreeHeterocercal
I just made a folder instead of file and was trying to edit the directory using VIM. That gave this error.:-)Phyllida
W
293
:set ma

which is short for

:set modifiable

will make a buffer modifiable. And

:set noma

does the opposite.

Wu answered 14/3, 2012 at 16:58 Comment(3)
+1 to this answer. Google shows this page when you search for the way to turn off the modifiable flag in a buffer.Robichaux
Does anyone knows how do I UNDO what I deleted in NERDTree? like 'dd' and then I tried to 'u' and nothing happensAbbey
I also had to use :set buftype: " " for writing the file after modification (afterwards message was Cannot write, 'buftype' option is set)Farm
D
21

I am not familiar with NERDTree but I guess that by typing a in a NERDTree view, it is interpreted as "I want to append something to the NERDTree buffer", but that buffer is not modifiable.

You can check out this answer vim and NERDTree extension - adding a file which explains how to add a file with NERDTree.

Dement answered 21/4, 2011 at 14:37 Comment(1)
That's it, checking the help for NERDTree there is no a mapping, which will cause it to try appending new text.Deedee
L
8

This worked for me:

:set buftype=
:w
Lathery answered 1/8, 2019 at 21:43 Comment(4)
what are you suppose to add after the = ?Moorman
Nothing. This means asign an empty value to buftypeLathery
Works for me too but how to make the change persistant? When I come back and into the file again I need to repeat this command.Incline
I am going throug the Tutor in nvim. Installed it on the mac with home brew.Incline
R
3

If you want to happen a file in NERDTree, you need to hit "m" (for menu) then "a". Simply entering "a" in NERDTree buffer will be interpreted as "modify NERDTree buffer". Adding :ma will make NERDTree buffer modifiable, but this wont create new files for you, it will lead to inconsistent info between what NERDTree display and your actual file hierarchy.

Reductase answered 7/3, 2018 at 8:37 Comment(0)
R
2

Ok, this may not be the most informed answer as I barely have a working knowledge of vim or linux, But I have found to solution to my problem and it may work for you to. To be specific, My problem was twofold:

1) whenever i tried to edit something in this new file i created, i got the Cannot make changes, 'Modifiable' is off error and...

2) after running :set modifiable and trying to save, i would get an e382 error of 'cannot write, buftype is set. so i couldn't save.

After pouring throuch scads of useless cryptic documentation i figured out this:

1) find the .vimviews directory, for me it was at the root of my git repository, do an

ls 

inside it. i got something like this:

~=+www-halo=+test=+lib=+Halo=+Return2=+HeaderTest.php=
~=+www-halo=+test=+lib=+Halo=+Service=+LandmarkTest.php=
~=+www-halo=+test=+lib=+Halo=+Transaction=+AuthnetTest.php=

Which is totally useless to you since you have a different file structure. but look for the file that is giving you the problem. (oh btw, these are in fact file names, which is completely not obvious by looking at them). find the one that has the file in question and delete that sucker: example:

rm ~=+www-halo=+test=+lib=+Halo=+Return2=+HeaderTest.php=

Problem solved.

Rathe answered 8/10, 2012 at 23:52 Comment(1)
Have also gotten this problem working with NerdTree. This only worked after exiting the vim session that caused the issue. I'm guessing that it kept resetting this "view".Crumley
C
0

In case anyone else happens to google to this, check that you're not trying to open a directory in vim like I just was (d'oh)

Cannabin answered 21/9, 2012 at 11:23 Comment(2)
You can open directories in Vim. By default it will launch Netrw.Hyman
You can for example select files in a directory, :cw do some changes to their names and save itNuminous
P
0

For me, I had stashed changes which included a directory I was then trying to create a file in that dir I had just stashed. NERDTree was still showing the pre-stashed tree with that dir. Using m on a dir that does not exist produced the modifiable error. I should have refreshed the tree with r to see the dir was no longer there and why it could not be modified.

Pluvious answered 14/4, 2020 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.