Vim for Windows - What do I type to save and exit from a file?

前端 未结 7 2139
眼角桃花
眼角桃花 2020-12-12 09:01

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

相关标签:
7条回答
  • 2020-12-12 09:21

    Press ESC to make sure you are out of the edit mode and then type:

    :wq
    
    0 讨论(0)
  • 2020-12-12 09:30

    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:

    • http://bullium.com/support/vim.html provides an HTML quick reference card
    • http://tnerual.eriogerg.free.fr/vim.html provides a PDF quick reference card in several languages, optimized for print-out, fold and put on your desk drawer

    However, the best way to learn Vim is not only using it for Git commits, but as a regular editor for your everyday work.

    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.

    0 讨论(0)
  • 2020-12-12 09:37

    Use:

    :wq!
    

    The exclamation mark is used for overriding read-only mode.

    0 讨论(0)
  • 2020-12-12 09:43

    Esc to make sure you exit insert mode, then :wq (colon w q) or ZZ (shift-Z shift-Z).

    0 讨论(0)
  • 2020-12-12 09:43

    A faster way to

    • Save
    • and quit

    would be

    :x
    

    If you have opened multiple files you may need to do a

    :xa
    
    0 讨论(0)
  • 2020-12-12 09:45

    :q! will force an unconditional no-save exit

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