Reputation: 42278
I have in my home directory on Windows a task.otl
, which is a kind of Todo list, using the vim-outliner format.
When launching gvim without argument, I automatically load it. However, I would like to only open it once. So I want to check in my .vimrc
the existence of the swap file before opening it in a new session.
Whatever I do,
:echo filereadable(expand("$HOME/task.otl"))
always correctly returns 1
. It works with other file in my home directory as well.
However if I try,
:echo filereadable(expand("$HOME/.task.otl.swp"))
it always returns 0
. (even when the file is present in the directory)
For completeness, I have also tried with glob()
:echo glob(expand("$HOME/task.otl"))
returns the full path
:echo glob(expand("$HOME/.task.otl.swp"))
returns an empty string...
Further tests : test.swp
is not found & test.fwp
is found. So this is definetely an issue with extension.
I have tried set suffixes -= .swp
with no success.
Removing .swp
from wildignore
allows to find test.swp
with glob() but not .task.otl.swp
...
So my question would be how to test the existence of swap file in Vimscript ? Other solutions are also welcome.
Upvotes: 0
Views: 508
Reputation: 14959
The wildignore ignores the file starting with .
too.
I just managed to have the correct behaviour using
:set wildignore-= .*
Upvotes: 1