How to make a symbolic link to /usr/bin/vim but with start-up parameters

lnsymlinkvim

After I make&make install vim from source, I found many symbolic links of vim in /usr/local/bin, such as evim, rvim, view…

The vim(1) man page said that "rvim" is equivalent to "vim -Z" and so on.

Now I wonder: can I make such a symbolic link with ln(1) myself, and if so, how?

Best Answer

You can't without writing a bit of code.

Those symlink shortcuts work because vim is written that way. It looks at how (with what name) it was started and acts as if it had been called with the appropriate command line options.
This behavior is hardcoded in the executable, it is not a trick done by the symbolic link.

So if you want to do that yourself, the easiest is to write a small wrapper script that execs vim with the options you want:

#!/bin/sh
exec vim <options you want> "$@"

The "$@" at the end simply passes any command line options given to the script along to vim.

Related Question