1

I tried to quit vim

"/etc/sysconfig/network-scripts"
"/etc/sysconfig/network-scripts" E212: Can't open file for writing
Press ENTER or type command to continue

When I press Enter, it returns to edit mode. I tried

!q

Press ENTER or type command to continue
[No write since last change]
/bin/bash: q: command not found

shell returned 127

Press ENTER or type command to continue

I press Enter, it returns to the previous editor mode again.

How can I quit vim in this situation?

  • because you cannot replace q! with !q – Alvin Liang Dec 12 '18 at 9:45
2

If you want save changes :wq!, but if something wrong and you want quit anyway (ignore changes) - :q!

Often you can start edit file with no permissions to save it. You can make many changes and then understood, you can't save it. In this case i recommend save as it:

:w tmp_filename

then exit vim and replace old file with tmp_filename.

| improve this answer | |

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