简体   繁体   English

如何保存和退出 Vim?

[英]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.我正在尝试在 Linux 服务器上编辑 my.cnf 文件并使用 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.如果我做了这些建议中的任何一个,我就会回到 vim。 Also, ctrl-c does not work.此外,ctrl-c 不起作用。 Please help.请帮忙。 I need to end it with vim.我需要用 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.您会收到错误 127,这意味着“无效命令”,因为当您键入:!q它会调用一个外部命令:这里您正在尝试在不存在的 shell 中执行命令q

To force quit the command is :q!强制退出命令是:q! but if :wq doesn't work maybe that means that you don't have the permissions to edit your file.但是如果:wq不起作用,这可能意味着您没有编辑文件的权限。 If that's the case you should use sudoedit to edit your file.如果是这种情况,您应该使用sudoedit来编辑您的文件。

Also for vim specific questions try to ask your question on vi specific SE site it is still in beta but pretty reactive.同样对于 vim 特定问题,请尝试在vi 特定 SE 站点上提出您的问题,它仍处于测试阶段,但非常被动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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