Search code examples
bashvimredhatvi

I cannot use vi even after installing vim in RedHat


I'm not able to open file using vi command. I'm able to open with vim, but I'm not able to open with vi. This happened after I tried to enable syntax lighting(the coloring thing in terminal). I can open files with vim but not able to open with vi.

[root@123-dev-lnx ~]# vi index.html
bash: index.html: command not found...
[root@123-dev-lnx ~]# vim index.html
[root@123-dev-lnx ~]#

Solution

  • checking your aliases with

     alias | grep vi
    

    you saw

    alias vi=''
    

    which basically means that the vi command itself is replaced by nothing, leading the command:

    $ vi index.html
    

    to become

    $ index.html
    

    which tells the shell to launch a program named index.html which doe not exists.

    as suggested in cmments,

    unalias vi
    

    allowed to remove the alias and have the vi being called.

    That said, unless you have explicitly typed the bad alias in your console, it may be somewhere in your configuration files and will probably keep bothering you in the future...