Not reading ~/.vimrc

后端 未结 13 2116
借酒劲吻你
借酒劲吻你 2020-12-07 14:41

I have a ~/.vimrc file that vim doesn\'t seem to be reading. There is a file at /etc/vimrc, and it looks like it is using that one.

My understanding is that the one

相关标签:
13条回答
  • 2020-12-07 15:17

    Stumbled on this post and non of the suggestions worked for me. Some useful things not mentioned here:

    1. vim --version should give you some useful info including the startup files. (Mine listed "virc" in several places (not vimrc)
    2. If your vim isn't really vim then perhaps it is looking for ~/.exrc instead of .vimrc (Mine looks for some system vircs, then some users vircs and then $HOME/.exrc)
    3. If your file (whichever one it is) has DOS line endings it may cause errors

    ... so even though I've got a real vim, it's looking for "virc"

    0 讨论(0)
  • 2020-12-07 15:23

    if you're on linux and want to know if vim is accessing your ~/.vimrc on startup you can launch it with strace:

    strace -o vim_strace vim
    

    then quit vim. Open the vim_strace file and search for "vimrc" in the file. you should find a line like that

    stat64("/home/youruser/.vimrc", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
    

    which mean that at least vim sees the file.

    0 讨论(0)
  • 2020-12-07 15:23

    In case anyone else runs across this issue, and like me realizes .vimrc wasn't read because of sudo, try using sudo -E. It retains your environment for the command, and $HOME will point to your own home dir. Note this may not work in environments where /home is mounted with rootsquash.

    0 讨论(0)
  • 2020-12-07 15:30

    Just to add on hellvinz's instruction.

    After you have made vim_strace file.

    cat vim_strace | grep .vimrc

    makes life bit easy :)

    0 讨论(0)
  • 2020-12-07 15:30

    /etc/vim/vimrc is now overwritten by defaults.vim unless there is a ~/.vimrc, apparently. https://github.com/vim/vim/issues/2042

    0 讨论(0)
  • 2020-12-07 15:31

    If anyone happen upon this issue while using neovim you should know (before you start pulling off your hair) that the .vimrc file is loaded from ~/.config/nvim/init.vim.

    mkdir -p ~/.config/nvim; ln -s ~/.vimrc ~/.config/nvim/init.vim
    
    0 讨论(0)
提交回复
热议问题