I have in my .cvsrc:

cvs -q -e vim

I want to create an alias (like my-vim or something like that):

alias my-vim="vim -S ~/myscript.vim"

And do

cvs -q -e my-vim

Unfortunately, this doesn't work. What do I have to do to make an alias work inside cvs -e parameter?

  • 1
    The reason the alias doesn't work is that only the shell expands aliases, and likely cvs execs your editor without going through the shell, so it will have to be an actual command. – glenn jackman Feb 28 '11 at 21:02
  • 1
    @glenn: And even if cvs executes the editor via a shell, under most setups, aliases are only available in interactive shells (the others don't read .bashrc/.zshrc/…). – Gilles 'SO- stop being evil' Feb 28 '11 at 21:55

I don't know how to get the alias to work inside CVS, but what you can do is write a script which invokes vim the way you want.

The script would simply be:

vim -S ~/myscript.vim "$@" 

And then just save it somewhere in your $PATH with the name rvimmy-vim (for example /usr/local/bin/my-vim), and you should be able to use my-vim as a command both on your command-line and from within CVS.

If you don't want to put the script in a global directory on your system or don't have the rights to, just create $HOME/bin, put the script there, and add it to your $PATH.

| improve this answer | |
  • 1
    You can also create $HOME/bin and put all your scripts in there (and add it to PATH in your login profile). The CVS isn't going to know about shell aliases. – Keith Feb 28 '11 at 19:14
  • 1
    You would want to add "$@" as the filename argument to vim in that script. – glenn jackman Feb 28 '11 at 20:59
  • 1
    Also, rvim is already a command (restricted vim). OP might want to choose a different name. – glenn jackman Feb 28 '11 at 21:01
  • Thanks for the comments, I improved my answer based on your suggestions – Cedric Feb 28 '11 at 22:08
  • I'm doing your approach, but using $CVSEDITOR variable as suggested by @Gilles. Thank you both! – Somebody still uses you MS-DOS Mar 1 '11 at 17:17

Set the environment variable CVSEDITOR to your favorite editor. This is not expanded by the shell, so the tilde won't work. So write a one-line shell wrapper and call that in CVSEDITOR. Write this as ~/bin/CVSEDITOR and make it executable:

exec vim -S ~/myscript.vim

Then put the following line in your ~/.profile:


If you want to use the same editor for everything, set the EDITOR and VISUAL variables instead (set the both to the same value).

| improve this answer | |

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.