Monday, June 29, 2015

Catching "swap file exists" and dealing with it in code

Windows 32bit Vim 7.4.1-729

My work flow is this.

Have gVim open, editing a file.
Flip over to my revision system (Perforce) and do a diff on the file to have a look at the changes I have made with what is currently in the repository.

P4 just launches gvim -O -d %1 %2.

I am writing my own plugin to do something different like this instead:
gvim --servername gDiff +"RemoteDiffFiles '%1', '%2'"

If the file I choose to diff, so happens to be open in my usual editing Vim instance then Vim rightly displays the popup, indicating the .swp file exists and what I would like to do ... Open Read-Only, Delete it, Quit,...


What I want to be able to do is catch this message and deal with it in my own code and show a message.  

Greping through the vim74 directory, "Open Read-Only" seems to be part of the Vim binary itself.  

I know I can wrap my :edit / :view command in a try catch, but assuming I manage to catch this condition, is there a Vim command I can use in VimScript to make one of those choices?  My Googling around didn't get me what I needed.

TIA,
David


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: