Raphael Bauduin wrote:
On 3/16/07, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
Raphael Bauduin wrote:
> Hi,
>
> When opening a file, is there a way to tell vim which name to use for
> the swapfile?
>
> I'm writing a little vim config file to edit a CMS' content in a DB.
> Each page has a parts named 'body', which the script makes available
> through
> :Radiant edit pages/Home Page/body
> or, for another page:
> :Radiant edit pages/Home Page/Articles/First Post/body
>
> The problem is that vim is using the same swapfile due to the last
> part of the path being body in both cases. I see 2 solutions to this
> problem: either use no swapfile (resetting swapfile), or specify
> another name for the swapfile, with a preference for the latter. I can
> specify the directory where to put swapfiles, but can I specify a name
> for the swapfile? Or can I set a swapfile directory specific to a
> buffer?
>
> Thanks in advance for your help.
>
> Raph
>
>
IIUC, you can't specify the swapfile name; but (again, IIUC) the
default is to
write the swapfile in the same directory as the editfile: so you would
have
pages/Home Page/.body.swp
and
pages/Home Page/Articles/First Post/.body.swp
which are different files by virtue of being located in diferent
directories.
The swapfile used is .body.swp , it doesn't seem to create the
directories. I set directory=/tmp/ and the swapfile used is
/tmp/body.swp .
That's the problem. If you set the swapfile to always be written to a fixed
directory, there will be collisions.
If 'directory' starts with . (as in the default), Vim will attempt to create
the swapfile in the same directory as the editfile. There will be no need to
"create" the directory since it already contains the file you're editing, and
for the same reason it should be writable.
Remember the path is not the path to a real file, it's a path used by
an autocommand to find the data in a db.
so, where does your database reside? There is something I don't understand. If
your user-commands creates a buffer with a nonexistent path, then maybe the
"path" part of the buffer name should be changed.
Raph
The advantage of having the swap in the same directory as the
editfile, is
that it can always be spotted if you try to edit the same file in two
instances of Vim at the same time, or to reopen a file which wasn't
properly
closed because of a crash.
Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
118. You are on a first-name basis with your ISP's staff.
Next time, please use "Reply to All" (or Reply to List" if available), not
"Reply to Sender", and please don't use top-posting either. It seems to me
I've been writing this in at least one reply per day for a week. Don't you
people read what comes in your inbox?
Best regards,
Tony.
--
It's better to be wanted for murder that not to be wanted at all.
-- Marty Winch