Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better way to set undodir

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.  On
   Win32, when a separating comma is following, you must use "//", since
   "\\" will include the comma in the file name.

So we guarantee unique filenames. We're also talking advantage of
multiple arguments, so we'll use a CWD .vim/tmp folder if it's
available, or fall back to a system tmp folder.
  • Loading branch information...
commit 6d0886aa81b897b3b4e656b72615bcf79428e314 1 parent 8950f4a
@voxdolo voxdolo authored
Showing with 2 additions and 3 deletions.
  1. +2 −3 .vim/plugin/hashrocket.vim
View
5 .vim/plugin/hashrocket.vim
@@ -46,9 +46,8 @@ set list " show trailing whiteshace and tabs
if &statusline == ''
set statusline=[%n]\ %<%.99f\ %h%w%m%r%{HTry('CapsLockStatusline')}%y%{HTry('rails#statusline')}%{HTry('fugitive#statusline')}%#ErrorMsg#%{HTry('SyntasticStatuslineFlag')}%*%=%-14.(%l,%c%V%)\ %P
endif
-if isdirectory(expand('~/.vim/tmp'))
- set undodir^=~/.vim/tmp
-endif
+
+set undodir=~/.vim/tmp//,/var/tmp//,/tmp//,.
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_rails = 1

7 comments on commit 6d0886a

@tpope
Collaborator

Stop forcing stuff into my /var/tmp :(

@voxdolo

It prefers ~/.vim/tmp, which is what the previous setting did as well, only here, we fall through to /var/tmp and /tmp... have I messed up a unix idiom or something? Is this not actually working like I think it is?

@tpope
Collaborator

I mean I'm quite content to leave things in the same directory. This, in fact, has the small advantage of preserving across directory renames and whatnot. I'm arguing for prepending directories that you must create yourself, then fall back to ..

I tried to solve this in sensible.vim as well, but I can't say I have strong feelings that that's the correct place.

@voxdolo

So if I'm reading sensible.vim right, it looks for a ~/Library/Vim/undo or a ~/.local/share/vim/undo ? Both of which are directories you opt into the use of by creating them, right? I'm fine with that approach, if you consider that less invasive.

My thinking was: "I never want to see these files". I'd rather not have undodir set than have those files littering my CWD. I wanted somewhere that I could definitely stick them, falling back to a set place that you opted into if you didn't want them in your /var/tmp. Your logic is the inverse of mine, saying that "you should have to opt in to not have them in your CWD". My only fault with that line of thought is that it requires that you know the option exists. Most folks don't go source diving on .vimrc, they just use it (and if like me, get aggravated that .un~ files are getting pooped everywhere).

That said, if you feel like opt-in is better than sticking them somewhere out of sight (and really, incorrect, as they're not temporary files), then we can definitely change it to something closer to sensible.vim and I'll make sure I educate folks here about how to opt-out of undo files in CWD.

@tpope
Collaborator

You're correct. I've been considering making a separate plugin that additionally creates the directories for you, but I'm still fleshing out some of the details.

I think a solution that would satisfy everyone would be to have the dotmatrix install script do the mkdir for you. I can add that if you like.

@voxdolo

You're welcome to add it. If you don't get around to it, I can add it after work today.

@voxdolo

Okay, I've attempted to resolve this in a satisfactory manner here: bdbbb34 Cheers!

Please sign in to comment.
Something went wrong with that request. Please try again.