smartyollie
smartyollie

Reputation: 181

running vim on windows leaves unwritable swap files behind

I am running Cygwin on windows. Several times now I've had a swap file left behind from vim after a crash, but it can't be recovered or deleted. "ls -l" shows this: -rw-r----- 1 Unknown+User Unknown+Group 12288 Feb 26 15:27 .pl.pl.swp

I'm not allowed to be an admin on my box, so I can't delete it. I'm not the owner so I cant' delete it either - it has unknown ownership.

Any ideas on how I can delete it (without pulling in a machine admin each time)? Can I have vim put its swapfiles in some other folder so at least they won't clutter up my working dir (I need the right .vimrc settings for running on windows)?

Upvotes: 8

Views: 2243

Answers (2)

LinconFive
LinconFive

Reputation: 2012

in your case, windows platform,

option 1: using cmd console, go to the folder which contains the swp files

del /A:H *.swp

option 2: using cygwin console, go to the folder samely

find . -type f -name "*.sw[klmnop]" -delete

Upvotes: 0

romainl
romainl

Reputation: 196456

You can disable swapfiles entirely with set noswapfile or, if you still want that feature but not the clutter, tell Vim to put those files in a dedicated location:

set directory=c:\\tmp

Note that you'll still have to delete existing swapfiles manually.

Read the following help sections for more information:

:help 'swapfile'
:help swap-file
:help 'directory'

Upvotes: 4

Related Questions