Change Vim swap/backup/undo file name

前端 未结 3 897
青春惊慌失措
青春惊慌失措 2021-01-29 19:04

Is it possible to change the way Vim names its swap/backup/undo files?

To avoid clutter, I\'ve set options in my ~/.vimrc to dump these files in ~/.v

3条回答
  •  清酒与你
    2021-01-29 19:35

    I have this in my .vimrc and it names the swap files with full path names and percent signs just as you describe:

    " Store swap files in fixed location, not current directory.
    set dir=~/.vimswap//,/var/tmp//,/tmp//,.
    

    The key is the // at the end of the directories. See this note from :help dir:

    • For Unix and Win32, if a directory ends in two path separators "//" or "\\", the swap file name will be built from the complete path to the file with all path separators substituted to percent '%' signs. This will ensure file name uniqueness in the preserve directory.

提交回复
热议问题