20

I am using Vim on Windows and decided to create a separate directory for all my backup files created by vim.

I am using Vim from my command prompt and not using the vim GUI(gVim).

I looked at this post and added the following lines in my _vimrc

set backup
set backupdir = D:\\VimTemp

I have already created D:\VimTemp on my system.

Now whenever I try to save changes to my file using :w I get the following error message

"PenProperties.py" E510: Can't make backup file (add ! to override)

I have already tried setting the backupdir in the following ways:

  • set backupdir = D:\\VimTemp

  • set backupdir = "D:\\VimTemp"

  • set backupdir = "D:\\VimTemp\\"

  • set backupdir = "D:\VimTemp"

Now, I have already looked at similar questions on stackoverflow but the problem is still there.

So, my question is how to make this work properly.

Community
  • 1
  • 1
RanRag
  • 48,359
  • 38
  • 114
  • 167
  • You should also consider _set dir=_ which will move vim _swap_ files somewhere. See :help dir and note the _//_ syntax at the end ov the value, which will uniquify the filenames in the directory by prepending a string representing the path. – pb2q May 21 '12 at 20:35

2 Answers2

20

Kill the spaces around =

set backupdir=D:\\VimTemp

should work if you've created the directory.

pb2q
  • 58,613
  • 19
  • 146
  • 147
  • also: don't neglect the help command for vim problems --> :help backupdir – pb2q May 19 '12 at 14:08
  • Nice. It Worked. Thanks a lot man and yes from next time I will first look at `vim help`. – RanRag May 19 '12 at 19:55
  • 1
    @SJMP what platform are you running gvim in? The above uses windows-specific path naming conventions, so if you're running under linux/OSX then you'll need to adjust the command to point to the actual directory that you're trying to use. Also note that the command assumes the existence of the directory _VimTemp_ on the _D_ drive: If you're in windows, have you created that directory? – pb2q Apr 24 '14 at 18:26
  • 1
    I am running on Windows. I got it now. Thank you :-) – Sagar Jain Apr 25 '14 at 05:48
  • My problem was that I used single slash character for paths. – nurettin Jan 04 '18 at 08:01
0

On Linux, you can do by setting in editor- :verbose set backupdir?

Mohammad Shahid Siddiqui
  • 3,730
  • 2
  • 27
  • 12