Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thanks muru (+1). I think the last version is the least fiddly, although it'd be nice to specify both files with the initial command. I tested vim's -c <command>, but sudoedit won't take that. Presumably there are no other options? Commented Jan 10, 2018 at 6:19
  • @Sparhawk sudoedit treats all arguments as filenames, so the only way to pass on options to Vim via sudoedit would be to write a wrapper script. So as long as you have to specify a user-editable file, this would be a problem. See update for a possible wrapper script. Commented Jan 10, 2018 at 6:30
  • Gosh, that's pretty clunky, too. I think the third is still probably easier. Looks like it can't be done in a simple fashion, so I'll accept this answer, unless anything else comes along. Cheers. Commented Jan 10, 2018 at 6:32
  • 1
    @Sparhawk you're using an alias anyway, so you can wrap the 4th method in a function instead: sudodiff () { SUDO_EDITOR="/path/to/foo.sh" DIFF_FILE="$2" sudoedit "$1"; }. Then the only clunky part is creating the wrapper script for first use. Commented Jan 10, 2018 at 6:35