You are not logged in.

#1 2016-01-13 15:38:42

_maxe
Member
From: DE
Registered: 2015-10-18
Posts: 25

vim wont source .vimrc

Hello all,

Ive got some problems with vim, and i cant figure it out how to solve it.

I always used the standard vim config but i wanted to get some new colors, plugins etc.

so i installed pathegon but it didnt worked.
tried vundle and this didnt worked either.

so i looked up if my .vimrc is getting loaded correctly, since for both vim bundle managers you need a working vimrc

i wrote a simple setting in it, set ruler, which should always show me the current position.
And as i thought, it didnt changed anything.

I tried vim -V to see what happens, this is the output:

>_LC_ALL=C vim -V
chdir(/etc)
fchdir() to previous dir
sourcing "/etc/vimrc"
Searching for "archlinux.vim" in "/root/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/root/.vim/after"
Searching for "/root/.vim/archlinux.vim"
Searching for "/usr/share/vim/vimfiles/archlinux.vim"
chdir(/usr/share/vim/vimfiles)
fchdir() to previous dir
line 11: sourcing "/usr/share/vim/vimfiles/archlinux.vim"
finished sourcing /usr/share/vim/vimfiles/archlinux.vim
continuing in /etc/vimrc
Searching for "/usr/share/vim/vim74/archlinux.vim"
Searching for "/usr/share/vim/vimfiles/after/archlinux.vim"
Searching for "/root/.vim/after/archlinux.vim"
finished sourcing /etc/vimrc
chdir(/root)
fchdir() to previous dir
could not source "$HOME/.vimrc"
chdir(/root/.vim)
fchdir() to previous dir
could not source "~/.vim/vimrc"
chdir(/root)
fchdir() to previous dir
could not source "$HOME/.exrc"
Searching for "plugin/**/*.vim" in "/root/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/root/.vim/after"
Searching for "/root/.vim/plugin/**/*.vim"
Searching for "/usr/share/vim/vimfiles/plugin/**/*.vim"
Searching for "/usr/share/vim/vim74/plugin/**/*.vim"
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/getscriptPlugin.vim"
finished sourcing /usr/share/vim/vim74/plugin/getscriptPlugin.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/gzip.vim"
finished sourcing /usr/share/vim/vim74/plugin/gzip.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/logiPat.vim"
finished sourcing /usr/share/vim/vim74/plugin/logiPat.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/matchparen.vim"
finished sourcing /usr/share/vim/vim74/plugin/matchparen.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/netrwPlugin.vim"
finished sourcing /usr/share/vim/vim74/plugin/netrwPlugin.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/rrhelper.vim"
finished sourcing /usr/share/vim/vim74/plugin/rrhelper.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/spellfile.vim"
finished sourcing /usr/share/vim/vim74/plugin/spellfile.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/tarPlugin.vim"
finished sourcing /usr/share/vim/vim74/plugin/tarPlugin.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/tohtml.vim"
finished sourcing /usr/share/vim/vim74/plugin/tohtml.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/vimballPlugin.vim"
finished sourcing /usr/share/vim/vim74/plugin/vimballPlugin.vim
chdir(/usr/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim74/plugin/zipPlugin.vim"
finished sourcing /usr/share/vim/vim74/plugin/zipPlugin.vim
Searching for "/usr/share/vim/vimfiles/after/plugin/**/*.vim"
Searching for "/root/.vim/after/plugin/**/*.vim"
Reading viminfo file "/root/.viminfo" info oldfiles
Press ENTER or type command to continue

As you see it wont source it, also its in my home directory.

Here is the output of :scriptnames inside vim

 1: /etc/vimrc                                                                                                                                                                               
  2: /usr/share/vim/vimfiles/archlinux.vim
  3: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
  4: /usr/share/vim/vim74/plugin/gzip.vim
  5: /usr/share/vim/vim74/plugin/logiPat.vim
  6: /usr/share/vim/vim74/plugin/matchparen.vim
  7: /usr/share/vim/vim74/plugin/netrwPlugin.vim
  8: /usr/share/vim/vim74/plugin/rrhelper.vim
  9: /usr/share/vim/vim74/plugin/spellfile.vim
 10: /usr/share/vim/vim74/plugin/tarPlugin.vim
 11: /usr/share/vim/vim74/plugin/tohtml.vim
 12: /usr/share/vim/vim74/plugin/vimballPlugin.vim
 13: /usr/share/vim/vim74/plugin/zipPlugin.vim

any help here? i dont know what to do.
I already wiped vim from my computer and installed it back again to start fresh, but it still wont work.

I hope i gave all the relevant information.

Greetings, max

Offline

#2 2016-01-13 15:43:36

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: vim wont source .vimrc

_maxe wrote:
could not source "$HOME/.vimrc"
chdir(/root/.vim)
fchdir() to previous dir
could not source "~/.vim/vimrc"
chdir(/root)

Why is it trying to read files in "/root"? Are you running it as root? Does the file "/root/.vimrc" exist? Is that what you mean to do?

Last edited by drcouzelis (2016-01-13 15:43:58)

Offline

#3 2016-01-13 15:49:53

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: vim wont source .vimrc

If you're not running as root, something is definitely wrong. Otherwise I have no idea.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2016-01-13 15:56:30

_maxe
Member
From: DE
Registered: 2015-10-18
Posts: 25

Re: vim wont source .vimrc

Oh dang, i hadnt thought about that!!

It really was the problem that i ran it with sudo.
Had it in my bash_alias file. Looks like this wasnt a good idea.
I didnt understood the output of vim -V correctly so i never could have figured that out^^


Really thanks for the quick help.

Offline

#5 2016-01-14 19:35:33

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: vim wont source .vimrc

As it was told you run vim with sudo. By default it removes your current $HOME from environment list. Thus vim tries to use root home folder and does not find any config there.

You can use your current HOME if you run vim with
  sudo HOME=~ vim foo.c

Or edit sudoers file and uncomment line
  defaults env_keep += "HOME"

Update: Another way to preserver current user environment when using sudo is to pass '-E' flag to sudo. But I am not fully sure how secure such practice.

Last edited by anatolik (2016-01-14 19:39:46)


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#6 2016-01-14 20:01:41

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: vim wont source .vimrc

Added this information to Arch wiki https://wiki.archlinux.org/index.php/Vi … _with_sudo


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#7 2016-01-14 20:57:35

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: vim wont source .vimrc

IMO a better option is to use sudoedit; the editor is run as normal user. In the case of vim, your own configs will be sourced, modelines will function, etc. The only downside I know of is that you won't be able to edit any other root-owned files in that instance.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#8 2016-01-14 21:19:45

ayekat
Member
Registered: 2011-01-17
Posts: 1,634

Re: vim wont source .vimrc

Or to use vim's ! with tee:

:w !sudo tee %

or to make it rather elegant:

command W :execute ':silent w !sudo tee % > /dev/null' | :edit!

(source)

This doesn't allow you to edit files where you don't have read-permissions, though.


pkgs │ hacks │ cfg │ blag

Offline

#9 2016-01-14 23:48:19

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: vim wont source .vimrc

Use the vim plugin "vim-eunuch", available in the AUR.

:SudoWrite

Also comes with a command for

:SudoEdit /some/file/without/read/permissions

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#10 2016-01-15 13:50:38

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: vim wont source .vimrc

ayekat wrote:

or to make it rather elegant:

command W :execute ':silent w !sudo tee % > /dev/null' | :edit!

I love this. This is why Vim is simultaneously the best and worst text editor ever made. smile

Offline

Board footer

Powered by FluxBB