Search code examples
bashunixvi

.exrc not working


i am new to unix. I have created a .exrc file in my home folder. I just entered set nu and set ai in the .exrc to check. But whenever I'm opening vi editor, this doesn't work.

Further, I entered as superuser, by typing su and password, and now opened a new file in vi editor, now it is working.

Do we need to have superuser privilege to have this? Please help me on this.


Solution

  • Here's what I think is happening:

    1. vi is actually a link or alias to vim, a modern version of vi.
    2. You have a .vimrc file, which vim will read if present instead of .exrc.
    3. As superuser, vi is not a link to vim, and ignores .vimrc and reads .exrc.

    Check the output of

    $ which vi
    $ ls -l `which vi`
    $ ls ~/.vimrc
    

    The solution would be to use .vimrc instead of .exrc.