0

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'
else
  echom 'this is false'
endif

the result will be:

/root/vim_test/user.vim
this is false

Even though there is a valid file at the path.

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

4

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, privacy policy and cookie policy

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