If I run this code:

let s:user_config=fnamemodify('user.vim', ':p')
echom s:user_config
if filereadable("s:user_config")
  echom 'this is true'
  echom 'this is false'

the result will be:

this is false

Even though there is a valid file at the path.

Why this is happening? Am I passing the variables wrongly?

1 Answer 1


You're testing whether the file literally named "s:user_config" exists. Try this instead:

if filereadable(s:user_config)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.