vim “modifiable” is off

后端 未结 7 1029
悲&欢浪女
悲&欢浪女 2021-01-29 23:08

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 of

相关标签:
7条回答
  • 2021-01-29 23:38
    :set ma
    

    which is short for

    :set modifiable
    

    will make a buffer modifiable. And

    :set noma
    

    does the opposite.

    0 讨论(0)
  • 2021-01-29 23:39

    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.

    0 讨论(0)
  • 2021-01-29 23:51

    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)

    0 讨论(0)
  • 2021-01-29 23:51

    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.

    0 讨论(0)
  • 2021-01-29 23:52

    This worked for me:

    :set buftype=
    :w
    
    0 讨论(0)
  • 2021-01-29 23:53

    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.

    0 讨论(0)
提交回复
热议问题