My .vimrc is a directory and not a file, I don't remember doing an mkdir but oh well.

My problem is, I am on a school computer and don't have the rights to rm -rf the .vimrc file.

I am out of ideas. My original problem was that I got this error message when trying to open up something with Vim

Cannot source a directory: "$HOME/.vimrc"

  • If you want to use vim without configuration, just do vim --clean. If you do want to add your own configuration, we can manage that without sudo; I just need to check the docs first.
    – 3N4N
    Dec 1, 2022 at 10:49
  • 1
    Interesting. Anyhow, you should not need sudo rights, to remove a directory in your $HOME folder, just rm -rf $HOME/.vimrc should be enough, but perhaps just move it to some other space first, so that you can inspect the contents first: mv $HOME/.vimrc $HOME/.vimrc.old Dec 1, 2022 at 11:40
  • Maybe could you try to add a _vimrc file. That alternative is used for Windows but could work for Linux too. Dec 1, 2022 at 11:41
  • 1
    @3N4N for deleting a file in myself owend directory, I do not need admin rights. Even if the file belongs to root. The thing that matters is: you need to have write permissions in the folder that contains the file you want to delete. (unless the folder has the sticky bit) That's why I said should However, if this fails, this may indicate a filesystem or hard-drive damage Dec 1, 2022 at 15:35
  • 2
    rmdir ~/.vimrc? But given the rest I don't see why it would behave any differently.
    – D. Ben Knoble
    Dec 1, 2022 at 21:24

2 Answers 2


Problem :

Can not start vim because of Directory .vimrc , which itself can not be Deleted.

Solution :

Override .vimrc with custom location by starting vim with -u or -U on the command line.

Details :

To override , start vim with -u or -U on the command line.

vim -u myvimrc textfile

You can put some Defaults in "$HOME/myvimrc" or it could even be EMPTY file.

You can consider some other Path , eg "$HOME/myvim/myvimrc" , in which case you should give that Path to -u too.

You can check more about -u or -U to tweak accordingly.

Observation :

You should contact the School IT Dept Admin to login to your Computer to Delete the Directory. Then you can make the Correct .vimrc file.


You could try vim -u /path/to/.newvimrc, perhaps even add an alias for it in your shell to the standard vim command so you don't have to type the entire thing out, all the -u command does is specify an alternative .vimrc

To do so in bash/zsh add alias vim="vim -u ~/.rcnew" in your .bashrc or .zshrc somewhere and either restart your terminal or do source .bashrc for bash or source .zshrc for zsh

if you're on fish id recommend using an abreviation instead of an alias abbr vim vim -u ~/.rcnew, but if you want to use an alias instead add alias vim="vim -u ~/.rcnew" in your init.fish and then obv source ~/.config/fish/init.fish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.