0

I sometimes run vim as another user than me, using my own vimrc. In this case the swp and undo directory aren't writeable, and vim warns me with E303.

I don't care about not having swap file in this case, is there a way to disable this specific warning?

Or how can I check from vimrc that the directory isn't writeable?

  • 1
    I'm not sure if you can easily disable this error, but one solution would be to store swap files in ~/.vim/tmp/ (or ~/.cache/vim/) rather than the path of the file you're editing. See: vi.stackexchange.com/q/56/51 That will prevent conflicts between different users, as both users will have their own swap in their own home directory. – Martin Tournoij Apr 17 at 11:00
  • 1
    What user are you running as? If it’s root, I’d recommend sudoedit instead – D. Ben Knoble Apr 17 at 13:49
  • @MartinTournoij thanks, that's indeed the solution. I was using ~/.vim/swp for swap files, but $HOME was incorrectly kept to original user (me) in the sudo call. Using --set-home in sudo did the trick, so swap directory is now in a writeable place. – CharlesB Apr 18 at 7:07
  • @D.BenKnoble It's for another user than root. I didn't know about sudoedit, thanks. – CharlesB Apr 18 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.