git Vim for Windows - 我输入什么来保存和退出文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4708645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vim for Windows - What do I type to save and exit from a file?
提问by orokusaki
Using Windows XP I accidentally typed git commit -a
instead of git commit -am "My commit message"
, and now I'm viewing my CMD prompt filled with the file version of my commit message ("Please enter the commit message for your..."). I've added my message to the top, but now I can't figure out how to save and leave. I tried to press Ctrl+ W+ Q, but it doesn't do anything, but add ^
where the cursor is.
在使用 Windows XP 时,我不小心输入git commit -a
了git commit -am "My commit message"
,而现在我正在查看我的 CMD 提示,其中填充了我提交消息的文件版本(“请为您的...输入提交消息”)。我已将我的消息添加到顶部,但现在我不知道如何保存和离开。我试图按Ctrl+ W+ Q,但它没有做任何事情,而是添加^
光标所在的位置。
I also tried Escfirst, and then Ctrl+ W+ Q, but it says No write since last change (add ! to override)
.
我也试过Esc,然后再Ctrl+ W+ Q,但它说No write since last change (add ! to override)
。
回答by nunopolonia
Press ESCto make sure you are out of the edit mode and then type:
按ESC以确保您已退出编辑模式,然后键入:
:wq
回答by eckes
Instead of telling you how you could execute a certain command (Esc:wq), I can provide you two links that may help you with VIM:
我不会告诉您如何执行某个命令 ( Esc:wq),而是提供两个链接来帮助您使用 VIM:
- http://bullium.com/support/vim.htmlprovides an HTML quick reference card
- http://tnerual.eriogerg.free.fr/vim.htmlprovides a PDF quick reference card in several languages, optimized for print-out, fold and put on your desk drawer
- http://bullium.com/support/vim.html提供 HTML 快速参考卡
- http://tnerual.eriogerg.free.fr/vim.html提供多种语言的 PDF 快速参考卡,针对打印输出、折叠和放在办公桌抽屉上进行了优化
However, the best way to learn Vim is not only using it for Git commits, but as a regular editor for your everyday work.
然而,学习 Vim 的最佳方式不仅是将其用于 Git 提交,而且是将其用作日常工作的常规编辑器。
If you're not going to switch to Vim, it's nonsense to keep its commands in mind. In that case, go and set up your favourite editor to use with Git.
如果你不打算切换到 Vim,记住它的命令是无稽之谈。在这种情况下,去设置你最喜欢的编辑器以与 Git 一起使用。
回答by ephemient
Escto make sure you exit insert mode, then :wq
(colon w q) or ZZ
(shift-Z shift-Z).
Esc确保退出插入模式,然后:wq
(colon wq) 或ZZ
(shift-Z shift-Z)。
回答by sjas
Press
i
ora
to get into insert mode, and type the message of choicePress
ESC
several times to get out of insert mode, or any other mode you might have run into by accidentto save,
:wq
,:x
orZZ
to exit without saving,
:q!
orZQ
按
i
或a
进入插入模式,然后键入选择的消息按
ESC
几次退出插入模式,或您可能偶然遇到的任何其他模式保存、
:wq
、:x
或ZZ
退出而不保存,
:q!
或ZQ
To reload a file and undo all changes you have made...:
要重新加载文件并撤消您所做的所有更改...:
Press several times ESC
and then enter :e!
.
按几次ESC
然后输入:e!
。
回答by Fabian Schuh
A faster way to
一种更快的方式
- Save
- and quit
- 节省
- 并退出
would be
将是
:x
If you have opened multiple files you may need to do a
如果您打开了多个文件,您可能需要执行
:xa
回答by Marc B
:q!
will force an unconditional no-save exit
:q!
将强制无条件不保存退出
回答by Hedego
Use:
用:
:wq!
The exclamation mark is used for overriding read-only mode.
感叹号用于覆盖只读模式。