官术网_书友最值得收藏!

Persistent undo and repeat

Like any editor, Vim keeps track of every operation. Press u to undo a last operation, and Ctrl r to redo it.

To learn more about Vim's undo tree (Vim's undo history is not linear!) and how to navigate it, see chapter 4Advanced Workflows .

Vim also allows you to persist undo history between sessions, which is great if you want to undo (or remember) something you've done a few days ago!

You can enable persistent undo by adding the following line to your .vimrc:

set undofile

However, this will litter your system with an undo file for each file you're editing. You can consolidate the undo files in a single directory, as seen in the following example:

" Set up persistent undo across all files.
set undofile
if !isdirectory("$HOME/.vim/undodir")
call mkdir("$HOME/.vim/undodir", "p")
endif
set undodir="$HOME/.vim/undodir"

If you're using Windows, replace the directories with %USERPROFILE%\_vim\undodir (and you'll be making changes to _vimrc instead of .vimrc).

Now, you'll be able to undo and redo your changes across sessions.

主站蜘蛛池模板: 封开县| 都江堰市| 雷州市| 彭泽县| 乃东县| 丰原市| 伊金霍洛旗| 京山县| 荣成市| 富阳市| 临安市| 东辽县| 葫芦岛市| 阜新市| 邻水| 惠州市| 临安市| 迭部县| 固镇县| 洪雅县| 偏关县| 惠水县| 唐河县| 乌兰县| 淅川县| 留坝县| 嘉善县| 吉木萨尔县| 泸州市| 河池市| 石柱| 江山市| 耒阳市| 岳普湖县| 县级市| 鄂伦春自治旗| 顺义区| 东山县| 随州市| 彝良县| 廊坊市|