[Emacs学习笔记]停止与撤销

来源:互联网 发布:淘宝上刷到单的步骤 编辑:程序博客网 时间:2024/05/18 14:22

Emacs:撤销与停止命令

-> Sometimes you start a command by accident or change your mind about it. Don’t worry: with Emacs, you can quit in the middle or undo it.

停止命令

当输入错误一个命令的时候,当你想停止任何一个正在执行中的命令的是时候,使用 C - g 来停止当前操作。这是一个非常有用的命令,能够结束当前正在进行的操作,重新回到编辑文本的模式中。

撤销少量内容

C - x u

使用 C - x u 来进行撤销,这是一个最常用的撤销命令

-> By typing C-x u repeatedly, you can gradually work your way back to a point before your mistake. Although the undo command is very powerful, saving your file frequently, if not compulsively, is nevertheless a good idea. We usually save a file whenever we stop typing—even if only for a few seconds. Train your fingers to press C-x C-s whenever you pause; it’s a good habit to form.

重做(redo)

当撤销一个操作之后,如果想重做被撤销的操作,只需要把光标移到文本的任意地方,再重新使用 C-x u 命令,即可对钢材撤销的命令进行重做。

-> What if you’d like to redo a command after you type undo ? There is no formal redo command, but you can use undo in the following way. Just move the cursor in any direction, and type C-x u again. Emacs redoes the last command you undid. You can repeat it to redo previous undo s.

撤销大量内容

对于大量的内容,频繁使用 C-x u 将会显得很缓慢,笨拙。在Emacs中,则会有一些更加快速的方法进行对大量内容的撤销。

恢复文件到上次储存后

有人会问嘛,撤销文件储存后到现在的所有操作,关闭文件再打开不就可以了?然而现在有了新的方法。 使用 M-x revert-buffer RETURN 命令可以恢复到保存文件时的样子(抱歉,并没有快捷键)。

使用的时候如下图:
Revert

输入 yes 之后即可恢复内容,而如果在这个时候改变了想法,输入no 即可。

还原文件

其实这里英文原文说的还是很明白的,大概意思就是说:
每储存一个文件的时候,Emacs 会自动创建一个备份,这个备份的名字是 以前的文件名 加上 ,当灾难性的事情发生的时候,可以使用打开 以前的文件名 加上 ,再储存为一个真实文件的方法来恢复文件,这样的方式是一种方便的恢复、还原文件的方法。

-> The first time you save a file, Emacs creates a backup file. If something disastrous happens, and the other techniques for undoing changes won’t help you, you can always return to the backup file. The name of the backup file is the same as the name of the file you’re editing, with a tilde ( ~ ) added. For example, if you are editing the file text , the backup file is text~ .

-> *Emacs doesn’t provide any special commands for restoring a buffer from the backup copy. The easiest way to do this is to edit the backup copy and then save it as the real file. For example, if
you were working with a file called text , you could: exit Emacs by typing C-x C-c , then start Emacs again by typing emacs text~ . After the backup file is displayed, save it as the real file by typing C-x C-w text RETURN . As a safeguard, Emacs asks you before it writes over the original file.*

0 0
原创粉丝点击