简体   繁体   中英

How do I save and quit from Vim?

I'm trying to edit a my.cnf file on a Linux server and edited using vim. After doing my edits, I am unable to escape. I have tried exiting using the following methods:

  • q
  • !q
  • wq
  • !wq

None of these methods have worked. Upon exiting, it gives me the line:

shell return 127
Press ENTER or type command to continue

If I do either of those suggestions, I go back to vim. Also, ctrl-c does not work. Please help. I need to end it with vim.

You get an error 127 which means "invalid command" because when you type :!q it calls an external command: Here you're trying to execute the command q in your shell which doesn't exist.

To force quit the command is :q! but if :wq doesn't work maybe that means that you don't have the permissions to edit your file. If that's the case you should use sudoedit to edit your file.

Also for vim specific questions try to ask your question on vi specific SE site it is still in beta but pretty reactive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM