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

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.

主站蜘蛛池模板: 荣成市| 宜兰县| 锡林浩特市| 来安县| 克什克腾旗| 象山县| 历史| 都江堰市| 青神县| 凌海市| 中山市| 方山县| 株洲县| 靖江市| 达日县| 阿巴嘎旗| 财经| 盘山县| 云安县| 大方县| 新丰县| 汨罗市| 大关县| 盐池县| 景洪市| 天全县| 额敏县| 金阳县| 麟游县| 镶黄旗| 榆树市| 平原县| 罗源县| 衡阳县| 乌兰浩特市| 海门市| 进贤县| 陈巴尔虎旗| 芷江| 邢台市| 海晏县|