vim “modifiable” is off

℡╲_俬逩灬. 提交于 2020-01-11 14:51:15

问题


Trying to create a new file with nerd tree. 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 and Janus (almost out of the box)


回答1:


:set ma

which is short for

:set modifiable

will make a buffer modifiable. And

:set noma

does the opposite.




回答2:


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

You can check that answer vim and NERD Tree extension - adding a file which explains how to add a file with Nerdtree.




回答3:


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.




回答4:


This worked for me:

:set buftype=
:w



回答5:


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.




回答6:


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)



来源:https://stackoverflow.com/questions/5745506/vim-modifiable-is-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!