This question already has an answer here:

This is an alias defined in my Linux shell:

$ alias vi
alias vi='vim'

This alias is so stupid that I want to delete it definitely.

Is there a command to find where alias vi='vim' might have been defined? Something like Vim's :verbose [option]??


After hours of search, I found that alias vi=vim is located in /etc/profile.d/vim.sh, which is sourced by /etc/bashrc, which is sourced by .etc/.bashrc, which is sourced by ~/.bash_profile. Such a long journey!

Though I have located alias vi=vim, There is still a question:

Is there an easier way to do this? Is there a way that answer these question: Is alias defined through the command line, a script file, or something else? If defined in a script file, which file it is?

The method used above is "brute-force search". There maybe a dozen files that sourced by ~/.bash_profile. It is so inefficient that it spent me hours to debug.

marked as duplicate by Gilles shell Dec 19 '15 at 22:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    hmmm... is the command you are looking for not alias then? oh wait, i see - you're talking about in the text editor. i think you want either : abbrev or : map. no - that's not it either. you want to know where it was defined? you could try grep -l 'alias vi' ~/.* to start. – mikeserv Dec 19 '15 at 7:39
  • @mikeserv Yes, I want to know where alias vi='vim' locate. I want to delete that statement. That alias is really terrible. – Feng Yu Dec 19 '15 at 7:47
  • hahahaha!!! do the grep - it's almost definitely in one of your dot files in $HOME - probably some ~/.shellrc or ~/.profile or ~/.shenv or something like that. the grep will spit out the file name. you could do: grep -n 'alias vi' ~/.* /dev/null to ensure you get the whole matched line and the filenames and the line numbers for wherever it is matched. – mikeserv Dec 19 '15 at 7:49
  • 1
    I am not sure that substitution vi <-- vim have done via alias. In deb-distro such operation is provided via update-alternatives – Costas Dec 19 '15 at 11:26
  • 1
    Please execute type -a vi to find out if there is an alias defined for vi. – user79743 Dec 20 '15 at 0:00

Browse other questions tagged or ask your own question.