3

Is it possible to use gvim --remote-silent and similar as an editor for visudo and sudoedit? Actually, I don't think this is related to the --remote option. Even if I set Defaults editor = "/usr/bin/gvim", the tmpfile gvim loads is blank and editing it has no effect.

3

gvim returns almost immediately. When sudoedit notices that the editor has returned it will finish reporting no changes. To get sudoedit to work correctly you need to get it to wait until you are finished editing. I normally use -f switch to do this. I have not tried it but the manual seems to support the use of --remote-wait or --remote-wait-silent.

  • I thought the same thing, but --remote-wait doesn't work any better. -f does work, though! – ABP Dec 2 '13 at 21:25
2

You could try this using the environment variables:

  • EDITOR
  • SUDO_EDITOR
  • VISUAL

And setting one/all to this:

"/usr/bin/gvim --remote-silent"
  • My understanding of the documentation is that I should be able to specify a list of acceptable editors like Defaults editor = "/usr/bin/vim:/usr/bin/gvim:/usr/bin/gvim --remote-silent", and have sudo choose the editor in EDITOR as long as it's from that list. However, it seems that sudoedit uses vim even if EDITOR="/usr/bin/gvim --remote-silent". – ABP Dec 2 '13 at 19:31
  • Can you change it per the instructions here? viewsby.wordpress.com/2012/01/07/…, let me know, if so I'll add this to my A. – slm Dec 2 '13 at 19:33
  • Sorry, I don't have a program called update-alternatives on my machine. Seems like a Debian/Ubuntu specific solution. For example, the default editor for my visudo without any other settings seems to be vi, not nano. – ABP Dec 2 '13 at 19:41
  • I have that on CentOS/Fedora as well. – slm Dec 2 '13 at 19:42
  • Either way, from what I understand, update-alternatives just manages some symlinks to replace one program with another. This doesn't seem to me to be a correct solution. I actually can force sudo to use gvim with whatever options I want if it's the only thing in the Defaults editor setting, but it doesn't behave correctly. IDK if this is a bug in gvim or sudo, or if I'm doing something wrong. – ABP Dec 2 '13 at 19:53

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.