0

I'm on Mac OS X, but I guess this is the same for other unixes.

Every time I type vi on the terminal, I want to open the GUI version of Vim (in Mac OS it's called mvim).

For my user, I got it working adding an alias on my ~/.profile:

alias vi='mvim'

But when I have to sudo vi, it opens the terminal's vi, because it doesn't have the alias set.

I tried setting the alias for the root user on /etc/profile but it did not work. I also tried making /usr/bin/vi a symbolic link to mvim, but it didn't work either.

How can I make it so evey time any user, including root, types vi on the Terminal, it opens the windowed Vim?

1

/etc/profile is not evaluated when you run sudo ... as far as I know and the problem with the symbolic link is the mvim script; if you look at it, it has these lines:

# GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac

Since you started it with sudo vi the name does not fullfil the criteria to launch in GUI mode.

You could simply replace those two lines with gui = true to "force" GUI mode, but I am not sure what else this might break.

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.