Hacker News new | ask | show | jobs
by thwarted 5444 days ago
I made a script that opens all the files I need. I call the script with: :source scriptname.

Only problem is that the script works only if I open vim with 'vim' and not with 'sudo vim' (by the way, why is that?).

Based on what you've said, I'm not sure if this is an sudo issue or a vim issue. Where is scriptname, and where are the files that scriptname references? Your sudoers may be set up to replace the environment in such a way that vim looks relative to root's home directory rather than your user's home directory. You may need to copy your ~/.vim directory to ~root/.vim, if ~/.vim is where you've put scriptname and the other things it loads. Or you can move these into a system-wide path that vim searches.

1 comments

It might be worth running :cd in the sudo vim instance and in the regular one. Your sudo current directory could well be different to your own which would explain vim not being able to find the script.
That was the reason. Cleaver to think of that.