In neovim, we can get default standard path via stdpath() function. I wonder if there is any way to do that in vim.

below is the help doc about stdpath() in neovim:

stdpath({what})                 *stdpath()* *E6100*
        Returns |standard-path| locations of various default files and

        {what}       Type    Description 
        cache        String  Cache directory. Arbitrary temporary
                             storage for plugins, etc.
        config       String  User configuration directory. The
                             |init.vim| is stored here.
        config_dirs  List    Additional configuration directories.
        data         String  User data directory. The |shada-file|
                             is stored here.
        data_dirs    List    Additional data directories.

            :echo stdpath("config")
  • I don't think there are equivalents for most of those directories in Vim. The closest might be $VIM for stdpath(config).
    – muru
    Mar 10 '20 at 6:09
  • @muru The equivalent of "config" is actually ~/.vim on Linux/Unix/MacOS or $HOME/vimfiles on Windows. It's the user configuration directory...
    – filbranden
    Mar 10 '20 at 6:14
  • 1
    @filbranden ah, yes. When the docs said 'The environment variable "$VIM" is used to locate various user files for Vim, such as the user startup script ".vimrc".' I assumed it was actually talking about ~/.vimrc. But turns out that's only for Windows and Amiga (?!).
    – muru
    Mar 10 '20 at 6:26
  • Thank you for the answer.
    – ZMJ
    Mar 11 '20 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.