I use Vim a lot, and I know how I can start vim in insert mode. So I have an alias named vii in my .bash_aliases file.

On other hand I use Git a lot too, and I have this line in my .gitconfig:

    editor = vi

To write a commit message the vi editor is opened every time and I have to go in insert mode. So I thought of replacing vi with vii, and did.

But the problem is when I do git commit, instead of opening the vim in insert mode, it gives this error:

error: cannot run vii: No such file or directory
error: There was a problem with the editor 'vii'.
Please supply the message using either -m or -F option.

This makes clear that git does not looks to .bash_aliases file, even it isn't related to bash in any way. It does directly looks if there is /usr/bin/vii or not. And executes it if it is.

The Question

Can I place the aliased version of vi as vii in /usr/bin/?

(and please don't suggest me to use git commit -m "<commit message>". There are other situation where I need vim in insert mode.)

2 Answers 2


Aliases are internal to each of your current shell environments - they are expanded by the currently running shell (bash in your case), so they only have effect on what you execute by typing/pasting in your terminal.

You have at least two options here:

  • create a wrapper script named vii that will execute vim -c 'startinsert' and put it preferably in /usr/local/bin/ (or $HOME/bin, if it exists and is in your search path). The script only needs to contain

    exec vim -c 'startinsert' "$@" 2

    (Make sure to make it executable by running chmod +x /usr/local/bin/vii.) Depending on the PATH configuration of your git/other programs, you may need to specify full path to that wrapper script (i.e., editor = /usr/local/bin/vii).

  • If it is ok for you to have vim always start in insert mode, configure it to do so by adding startinsert at the end of .vimrc.

1   You can write the "she-bang" line as #!/bin/bash, but there's no need to in a script that contains no bashisms.
2   $@ must be in double quotes in case the script is ever called with argument(s) that contain space(s). startinsert does not need to be quoted (but it doesn't hurt).


Just set the editor variable to

    editor = vim -c 'startinsert'

For your other answer, no, you can't place aliases in a directory, as an alias is a concept from your shell. The normal way is to create an appropriate wrapper script to execute the specified commands, e.g.,

vim -c 'startinsert' "$@"

and save the script as vii and make it executable. You can place the script wherever you like, but typically such scripts are saved in somewhere in your $HOME folder like $HOME/bin and not in the global directories.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .