## 3. 撤销

Almost anything you do to an image in GIMP can be undone. You can undo the most recent action by choosing Edit → Undo from the main menu, but this is done so frequently that you really should memorize the keyboard shortcut, Ctrl+Z.

Undoing can itself be undone. After having undone an action, you can redo it by choosing Edit → Redo from the main menu, or use the keyboard shortcut, Ctrl+Y. It is often helpful to judge the effect of an action by repeatedly undoing and redoing it. This is usually very quick, and does not consume any extra resources or alter the undo history, so there is never any harm in it.

| 小心
如果您撤消一个或多个操作，然后以除使用撤消或重做以外的任何方式对图像进行操作，则将无法再重做这些操作：它们将永远丢失。如果它给您带来问题，解决方案是复制图像，然后在副本上进行测试。（别测试原图，因为当你复制图像时，不会复制撤销/重做历史。）

如果您经常发现自己一次撤消和重做许多步骤，使用撤消历史对话框可能更方便，这是 一个可停靠的对话框，显示撤消历史中每点的小草图，允许您返回或单击前进到该点。

| 提示
If you make a small mistake while actively drawing with a mouse like painting a little too far in one direction (over an important line, etc) you can also cancel the action early by pressing both mouse buttons at the same time then releasing the left (primary) button first. Canceling an action in this manner is even faster than accessing the Undo command (it avoids adding the action to the Undo History at all).

撤消是在特定于图像的基础上执行的：“撤消历史”是图像的组成部分之一。为此，GIMP会为每个图像分配一定数量的内存。您可以使用首选项对话框的系统资源页面自定义你的偏好设置以增加或减少数量。有两个重要的变量：最小撤消级别数，无论它们消耗多少内存，GIMP都将保持该数量；以及最大撤消内存数，超过该数量， GIMP将开始从撤消历史记录中删除最旧的项目。

| 注意
即使撤消历史是图像的一个组成部分，当您使用GIMP的原生 XCF 格式（它保留了所有其他图像属性）保存图像时，它也不会被保存。当图像重新打开时，它会有一个空的撤消历史。

GIMP的撤销实现相当复杂。许多操作只需要很少的撤消内存（例如，更改图层的可见性），因此您可以在它们退出撤消历史记录之前执行较长的操作序列。某些操作（例如更改图层可见性）被压缩，因此连续执行多次这些操作只会在撤消历史记录中生成一个点。但是，还有其他操作可能会消耗大量撤消内存。大多数滤镜是由插件实现的，所以GIMPcore 没有有效的方法来知道发生了什么变化。因此，除非在操作前后记住受影响层的全部内容，否则无法实现撤消。在它们退出撤消历史记录之前，您可能只能执行一些此类操作。

### 3.1. 不可撤销的操作

Most actions that alter an image can be undone. Actions that do not alter the image generally cannot be undone. Examples include saving the image to a file, duplicating the image, copying part of the image to the clipboard, etc. It also includes most actions that affect the image display without altering the underlying image data. The most important example is zooming. There are, however, exceptions: toggling Quick Mask on or off can be undone, even though it does not alter the image data.

有一些重要的操作会改变图像但无法撤消：

关闭图像

  撤消历史是图像的一个组成部分，因此当图像关闭并释放其所有资源时，撤消历史就消失了。因此，除非图像自上次保存后没有被修改，否则GIMP总是会要求您确认是否确实要关闭该图像。

恢复图像

  “恢复” 表示从文件中重新加载图像。GIMP实际上是通过关闭图像并创建新图像来实现的，因此撤消历史会丢失。因此，如果图像不干净，GIMP会要求您确认是否确实要还原图像。

操作的“片断”

  Some tools require you to perform a complex series of manipulations before they take effect, but only allow you to undo the whole thing rather than the individual elements. For example, the Scissors Select tool requires you to create a closed path by clicking at multiple points in the image, and then clicking inside the path to create a selection. You cannot undo the individual clicks: undoing after you are finished takes you all the way back to the starting point. For another example, when you are working with the Text tool, you cannot undo individual letters, font changes, etc.: undoing after you are finished removes the newly created text layer.

Filters, and other actions performed by plug-ins or scripts, can be undone just like actions implemented by the GIMP core, but this requires them to make correct use of GIMP's Undo functions. If the code is not correct, a plug-in can potentially corrupt the Undo History, so that not only the plug-in but also previous actions can no longer properly be undone. The plug-ins and scripts distributed with GIMP are all believed to be set up correctly, but obviously no guarantees can be given for plug-ins you obtain from other sources. Also, even if the code is correct, canceling a plug-in while it is running may corrupt the Undo History, so it is best to avoid this unless you have accidentally done something whose consequences are going to be very harmful.

2.3. 对话框和停靠 |  | 4. 常见任务

Report a bug in GIMP Report a documentation error