Question: How do I get the directory Vim is 'looking into'? I want to set up my `vimrc` platform independent so I don't want to put explicit directories. On Linux e.g. vim looks into `~/.vim` and on Windows in `~\vimfiles`. How can I get the directory that is used, to put my files there?

Answer: 
I can't say this is an information we never need as I have one use for it.

In lh-vim-lib, I proceed this way (in [lh#path#vimfiles()](https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/path.vim#L525)):

* First I build a regex from $HOME (i.e. I replace all slashes and backslahes into `[/\\]`): `:let regex = substitute($HOME, '[/\\]', '[/\\\\]', 'g')`.
* Then I append the possible directories: `let regex .= '\(vimfiles\|.vim\)'`
* And i finally, I search for my regex into &rtp. The shortest result is the good one. `:let paths = filter(split(&rtp, ','), 'match(v:val, regex) != -1')` + `:return paths[lh#list#arg_min(paths, function('len'))]`

Note: The real code is a little bit more complex, generic and resilient (/resistant?) to errors.

PS: because of cygwin, testing for `has('win32')` is not enough.

EDIT: I've been asked to provide [`lh#list#arg_min()`](https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/list.vim#L430) definition. It can be found in lh-vim-lib. Its definition is quite simple and a little bit cumbersome (IMO)

```
function! lh#list#arg_min(list, ...) abort
  if empty(a:list) | return -1 | endif
  let Transfo = a:0 > 0 ? a:1 : function(s:getSNR(id))
  let m = Transfo(a:list[0])
  let p = 0
  let i = 1
  while i != len(a:list)
    let e = a:list[i]
    let v = Transfo(e)
    if v < m
      let m = v
      let p = i
    endif
    let i += 1
  endwhile
  return p
endfunction

```
You can override the default `'runtimepath'` to make Vim use the same `~/.vim/` on Windows, too. Just put this into your `~/.vimrc`:

```
if has('win32') || has('win64')
    let &runtimepath = substitute(&runtimepath, '\C\V' . escape($HOME.'/vimfiles', '\'), escape($HOME.'/.vim', '\&'), 'g')
endif

```