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

  • Mastering Vim
  • Ruslan Osipov
  • 225字
  • 2021-06-10 18:51:25

A word about swap files

By default, Vim keeps track of the changes you make to files in swap files. The swap files are created as you edit the files, and are used to recover the contents of your files in case either Vim, your SSH session, or your machine crashes. If you don't exit Vim cleanly, you'll be greeted by the following screen:

You can either hit r to recover the swap file contents, or d to delete the swap file and dismiss the changes. If you decide to recover the swap file, you can prevent the same message from showing up next time you open the file in Vim by reopening a file and running :e, and pressing d to delete the swap file.

By default, Vim creates files like <filename>.swp and .<filename>.swp in the same directory as the original file. If you don't like your file system being littered by swap files, you can change this behavior by telling Vim to place all the swap files in a single directory. To do so, add the following to your .vimrc:

set directory=$HOME/.vim/swap//
If you're on Windows, you should use set directory=%USERDATA%\.vim\swap// (note the direction of the last two slashes).

You can also choose to disable the swap files completely by adding set noswapfile to your .vimrc.

主站蜘蛛池模板: 迁安市| 东安县| 天全县| 盐津县| 深水埗区| 虎林市| 方城县| 遂平县| 台安县| 渭南市| 岳普湖县| 凤翔县| 边坝县| 郯城县| 台南市| 莲花县| 怀化市| 麟游县| 抚松县| 濮阳县| 府谷县| 锡林浩特市| 礼泉县| 江西省| 团风县| 江安县| 博野县| 庄浪县| 筠连县| 那坡县| 青川县| 南雄市| 九龙坡区| 湄潭县| 乌什县| 从江县| 绵阳市| 鲁甸县| 中宁县| 通城县| 土默特右旗|