Wednesday, September 12, 2012

Changing location of swap directory for selected files, how to?

Hello,

I would like to modify the value of 'dir' option for a few specific
files (e.g: all files in directory ~/Foo/). Had 'dir' been a buffer
local option, it would have been a easy thing,
au BufEnter ~/Foo/* set dir=newval

But 'dir' is global across buffers. Can anyone suggest workarounds?

I have tried
au BufEnter ~/Foo/* call ChangeDir()
au BufLeave ~/Foo/* call RevertDir()

function ChangeDir()
let b:tmp=&dir
set dir=newval
endfunction

function RevertDir()
exe 'set dir=' . b:tmp
endfunction

..but BufEnter fires *after* swap file is created.

If you want to know why I'm doing this - it is to prevent .swp files
being created in my DropBox folder (and retain default behavior in all
other cases)

-Karthick

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: