在vim编辑器中,我做了很多更改并使用
ZZ
命令保存并退出。但后来意识到我不需要这些更改了。是否有一种方式可以从某个缓冲区返回到保存之前的状态,该数据可能仍存储在其中。我在保存并退出后没有进行任何更改。Vim中有持久撤销选项,:h persistent-undo
注意:它在VIM 7.3版本中引入,因此对于早期版本,它将无法工作。
您可以通过在.vimrc
文件中添加以下文本来启用它:
if has('persistent_undo') "check if your vim version supports it
set undofile "turn on the feature
set undodir=$HOME/.vim/undo "directory where the undo files will be stored
endif
silent !mkdir -p ~/.vim/undo
来确保目录存在。这个解决方案假设你有写入权限来创建目录~/.vim/undo
。 - Miron Veryanskiy
:h persistent-undo
。 - FDinoffset undofile
set undodir=/home/<uname>/.vimundo/
- brokenfoot