VI 编辑器学习

Saving and Quitting a File

You can quit working on a file at any time, save your edits, and return to the Unix prompt. The vi command to quit and save edits is ZZ. Note that ZZ is capitalized.

Let’s assume that you do create a file called practice to practice vi commands, and that you type in six lines of text. To save the file, first check that you are in command
mode by pressing ESC , and then enter ZZ. and type :wq to both save your edits and quit. (:wq is equivalent to ZZ.)

Quitting Without Saving Edits

When you are first learning vi, especially if you are an intrepid experimenter, there are two other ex commands that are handy for getting out of any mess that you might create. What if you want to wipe out all of the edits you have made in a session and then return to the original file? The command:
:e! ENTER
returns you to the last saved version of the file, so you can start over. Suppose, however, that you want to wipe out your edits and then just quit vi? The command:
:q! ENTER
quits the file you’re editing and returns you to the Unix prompt. With both of these commands, you lose all edits made in the buffer since the last time you saved the file.
vi normally won’t let you throw away your edits. The exclamation point added to the :e or :q command causes vi to override this prohibition, performing the operation
even though the buffer has been modified.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值