From 8207d1cd697d1201013edc8fd66c6a4be9c4d853 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 6 Jan 2013 13:29:17 -0500 Subject: [PATCH] Provide a home for transient files --- README.markdown | 3 +++ plugin/sensible.vim | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.markdown b/README.markdown index b54bf7d..0ee4ebc 100644 --- a/README.markdown +++ b/README.markdown @@ -31,6 +31,9 @@ mostly `:set` calls.) Here's a taste: * `'incsearch'`: Start searching before pressing enter. * `'listchars'`: Show trailing whitespace. * `'scrolloff'`: Always show at least one line above/below the cursor. +* `'directory'`: Dump swap files under `~/.cache/vim/swap` (only if that + directory already exists). Also `'backupdir'` and `'undodir'`. Try + `mkdir -p ~/.cache/vim/{swap,backup,undo}`. * `nmap Y y$`: Make `Y` behaves like `C` and `D`. * `runtime! macros/matchit.vim`: Load the version of matchit.vim that ships with Vim. diff --git a/plugin/sensible.vim b/plugin/sensible.vim index 68f5c78..48898cf 100644 --- a/plugin/sensible.vim +++ b/plugin/sensible.vim @@ -47,6 +47,17 @@ set fileformats=unix,dos,mac set viminfo+=! +if isdirectory(expand('~/.cache/vim')) + if &directory =~# '^\.,' + set directory^=~/.cache/vim/swap// + endif + if &backupdir =~# '^\.,' + set backupdir^=~/.cache/vim/backup// + endif + if exists('+undodir') && &undodir =~# '^\.,' + set undodir^=~/.cache/vim/undo// + endif +endif if exists('+undofile') set undofile endif