Where should $VIM point to?

閲覧: 15 回
最初の未読メッセージにスキップ

Enan Ajmain

未読、
2022/10/07 1:14:262022/10/07
To: vim...@googlegroups.com
Where should `:h $VIM` point toward? Where vim is installed or where vim
configurations is situated? By default it points to where vim is
installed. But the help doc says:

> The environment variable "$VIM" is used to locate various user files
> for Vim, such as the user startup script ".vimrc".
^^^^^^

Is `$VIM` supposed to point to my user config folder or the installation
directory? What is its intended purpose?


P.S. I came to know about this variable from an SO question[1].

[1]: https://vi.stackexchange.com/q/38793/16280

--
Enan

Christian Brabandt

未読、
2022/10/07 2:25:272022/10/07
To: vim...@googlegroups.com

On Fr, 07 Okt 2022, Enan Ajmain wrote:

> Where should `:h $VIM` point toward? Where vim is installed or where vim
> configurations is situated? By default it points to where vim is
> installed. But the help doc says:
>
> > The environment variable "$VIM" is used to locate various user files
> > for Vim, such as the user startup script ".vimrc".
> ^^^^^^
>
> Is `$VIM` supposed to point to my user config folder or the installation
> directory? What is its intended purpose?

You should not be required to bother :)

By default, it points to the installation folder (the parent of the
vim90 folder, so typically /usr/share/vim). You can check from within
Vim by doing :echo $VIM

Note, it may contain the so-called system vimrc, as mentioned in the
output of :version

,----
| system vimrc file: "$VIM/vimrc"
`----


Best,
Christian
--
Letzte Worte eines Liebhabers:
"Stört's Dich wenn ich dabei lese?"

Enan Ajmain

未読、
2022/10/07 2:38:232022/10/07
To: vim...@googlegroups.com
On Fri, 7 Oct 2022 08:25:16 +0200
Christian Brabandt <cbl...@256bit.org> wrote:

> You should not be required to bother :)

I realize that. That's why I didn't know about this variable before. But
my question is -- sorry for prying -- is it _intended_ to point to
installation directory, i.e., the system's vim files? Or should it point
to user's vim files?

--
Enan

Christian Brabandt

未読、
2022/10/07 5:13:152022/10/07
To: vim...@googlegroups.com

On Fr, 07 Okt 2022, Enan Ajmain wrote:

No, I mentioned it already. It should point to the installation
directory (/usr/share/vim on my system here).

Best,
Christian
--
Ein Idealist ist ein Mensch, der anderen Menschen dazu verhilft, zu
Wohlstand zu gelangen.
-- Henry Ford

Tony Mechelynck

未読、
2022/10/07 5:13:452022/10/07
To: vim...@googlegroups.com
The user's Vim files are normally located, either (privately) at
$HOME/.vim/ (Unix) or $HOME/vimfiles/ (Windows), or
(installation-wide) at $VIM/vimfiles/ — or, in all cases, in the
after/ subdirectories of the same, depending on whether you want them
to be sourced before or after the corresponding scripts from the Vim
distribution.

There are rare cases (which I won't describe here — if they applied to
you you would know it, and what to do) where it is worth setting $VIM
to some nondefault value.

For details about where to put your own Vim scripts (other than your
vimrc or gvimrc which are in your home directory) see :help
'runtimepath'

Best regards,
Tony.

Enan Ajmain

未読、
2022/10/07 5:42:352022/10/07
To: vim...@googlegroups.com
On Fri, 7 Oct 2022 11:13:27 +0200
Tony Mechelynck <antoine.m...@gmail.com> wrote:

> There are rare cases (which I won't describe here — if they applied to
> you you would know it, and what to do) where it is worth setting $VIM
> to some nondefault value.

Thanks for the information. The thing is I knew all the things you
explained (not a terribly new user here; been using for five years).
Except the use case of $VIM. Which you "won't describe here." Any link
where I can read up on it?


--
Enan

Tony Mechelynck

未読、
2022/10/08 20:28:342022/10/08
To: vim...@googlegroups.com
Well, the Vim executables I compile myself come with $VIM defaulted to
/usr/local/share/vim and $VIMRUNTIME set to
/usr/local/share/vim/vim90/. Those from my Linux distro have $VIM set
to /usr/share/vim and $VIMRUNTIME set to /usr/share/vim/vim90. The
"system vimrc" is at, respectively, $VIM/vimrc and /etc/vimrc but
neither of them exist. My vimrc sets $VIM to /usr/share/vim so that
they both will find my user-written scripts (at $VIM/vimfiles and
below) at a common location. I don't touch $VIMRUNTIME so each of them
uses its own "distribution" scripts. This way, in the rare case that I
have to use the distro's Vim rather than my own, it will work
identically apart from a difference in patchlevels and in featureset.

The following lines do that, at the very top of my vimrc:

let $VIM = '/usr/share/vim'
set runtimepath=~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after

let $VIMSRC = expand('~/.build/vim/vim-hg/src', ':p')

The ":set runtimepath" statement is there to make sure that the new
value of $VIM is correctly taken up. $VIMRC is an environment variable
which I set within Vim to get easily at my Vim source.

Best regards,
Tony.

Enan Ajmain

未読、
2022/10/09 0:23:302022/10/09
To: vim...@googlegroups.com
On Sun, 9 Oct 2022 02:28:14 +0200
Tony Mechelynck <antoine.m...@gmail.com> wrote:

> Well, the Vim executables I compile myself come with $VIM defaulted to
> /usr/local/share/vim and $VIMRUNTIME set to
> /usr/local/share/vim/vim90/. Those from my Linux distro have $VIM set
> to /usr/share/vim and $VIMRUNTIME set to /usr/share/vim/vim90. The
> "system vimrc" is at, respectively, $VIM/vimrc and /etc/vimrc but
> neither of them exist. My vimrc sets $VIM to /usr/share/vim so that
> they both will find my user-written scripts (at $VIM/vimfiles and
> below) at a common location. I don't touch $VIMRUNTIME so each of them
> uses its own "distribution" scripts. This way, in the rare case that I
> have to use the distro's Vim rather than my own, it will work
> identically apart from a difference in patchlevels and in featureset.

Thanks. That clears pretty much everything. Just one question. Why are
the user-written scripts residing in /usr/share/vim instead of ~/.vim? I
assume that's an unrelated, personal reason.


--
Enan
全員に返信
投稿者に返信
転送
新着メール 0 件