Where apps hide your files
Vim and Neovim use different config files in different places, and neither file exists until you create it. Here is where each one looks, how to ask the editor which files it loaded, and where the extra data lands.
Vim (the /usr/bin/vim that ships with macOS, and Homebrew's Vim and MacVim):
~/.vimrc
Neovim:
~/.config/nvim/init.lua
~/.config/nvim/init.vim
Use one name or the other: Neovim reports error E5422 when both exist. Both are in hidden folders, so in Finder use Go > Go to Folder (⇧⌘G) or open them from Terminal:
open ~/.config/nvim
If the file or folder does not exist, you have not created a config yet. Both editors run fine without one.
Inside Vim or Neovim, this lists every script it loaded, in order, with the full path of your config:
:scriptnames
And this prints the path of your main config file:
:echo $MYVIMRC
If $MYVIMRC is empty, no user config was found. To see the places Vim looks, run vim --version in Terminal and read the lines headed system vimrc file, user vimrc file and so on.
On the Mac used for this guide, the Apple-built Vim 9.1 reported these:
| Kind | Path |
|---|---|
| System vimrc | /usr/share/vim/vimrc (the $VIM fallback is /usr/share/vim) |
| User vimrc | ~/.vimrc |
| 2nd user vimrc | ~/.vim/vimrc |
| 3rd user vimrc | ~/.config/vim/vimrc |
| User exrc | ~/.exrc |
| Defaults file | $VIMRUNTIME/defaults.vim |
Vim uses the first user vimrc it finds and ignores the rest. The system file sits on macOS's protected system volume, so you cannot edit it even with sudo; your settings go in the user file. One Mac-specific catch: Apple's system vimrc sets skip_defaults_vim, so the Apple-built Vim never loads defaults.vim, and syntax highlighting stays off until you switch it on yourself. Other builds can list different paths, which is why vim --version is the reliable source.
~/.vim folderPlugins, colour schemes and your own scripts go in ~/.vim (subfolders such as plugin, autoload, colors and pack). Plugin managers create their own folders under it. On the Mac used for this guide, ~/.vim held only a small .netrwhist, the history file written by Vim's built-in file browser.
Neovim follows the XDG convention, and its documentation lists these defaults on Unix:
| Purpose | Path |
|---|---|
| Config | ~/.config/nvim |
| Data (plugins, installed by managers such as lazy.nvim, usually go here) | ~/.local/share/nvim |
| State (the ShaDa history file lives here) | ~/.local/state/nvim |
| Cache | ~/.cache/nvim |
If you have set XDG_CONFIG_HOME (or the data, state and cache equivalents), Neovim uses those instead. The command :echo stdpath('config') prints the real config folder, and stdpath('data'), stdpath('state') and stdpath('cache') do the same for the others. The documented ShaDa file is $XDG_STATE_HOME/nvim/shada/main.shada, which is ~/.local/state/nvim/shada/main.shada by default.
Some Neovim distributions and starter kits put their own folders in these places. If a plugin manager is installed, its plugins are in the data folder, not the config folder.
Vim keeps command history, registers and marks in ~/.viminfo. It is a private file (the permissions on this Mac are owner-only) and can contain text you copied or typed, so do not share it. Neovim's equivalent is the ShaDa file above. Vim puts swap files next to the file being edited by default, as hidden files such as .notes.txt.swp; Neovim keeps them in ~/.local/state/nvim/swap instead. In both, the directory option decides. A leftover .swp after a crash is how Vim offers to recover your work.
Copy ~/.vimrc and ~/.vim for Vim, or ~/.config/nvim for Neovim, to the new Mac. Many people keep these in a Git repository. You usually do not need the data, state or cache folders, because plugin managers re-download plugins when the config asks for them. Time Machine includes hidden folders by default.
If you have no file yet, create ~/.vimrc with a few lines you can understand, for example set number for line numbers and syntax on. Save it, restart Vim and the change applies. To keep Vim's usual defaults as well, Vim's help suggests starting the file with unlet! skip_defaults_vim and then source $VIMRUNTIME/defaults.vim. For Neovim, create the folder with mkdir -p ~/.config/nvim and put your settings in init.lua inside it. Keep a copy of the file in a Git repository so you can restore it on another Mac. Start small and add one setting at a time, so you always know which line caused a problem.
macOS ships its own Vim, and Homebrew or MacVim can install another. They may read the same ~/.vimrc but have different features. which -a vim lists them all, and vim --version shows the version and whether it was built with features such as Python or clipboard support. If a setting works in one and not the other, the build is the first thing to compare.
Both locations are hidden dot-folders or files, and Spotlight and Finder searches leave results from them out.
Typing vimrc or init.lua into Everywhere lists every config of that name, including copies in old backups and dotfile repositories. A search for main.shada finds Neovim's history file. ⌘T opens a Terminal in the folder of the selected result. It matches file names only, so use :scriptnames to learn which one the editor really loaded.
Vim reads ~/.vimrc, or failing that ~/.vim/vimrc or ~/.config/vim/vimrc. None exists by default, so you create it. Inside Vim, :echo $MYVIMRC shows the file in use.
~/.config/nvim/init.lua or init.vim, never both. The location moves if XDG_CONFIG_HOME is set; :echo stdpath('config') prints the real one.
Plugin managers usually install into the data folder, ~/.local/share/nvim by default, not into the config folder. Check your manager's docs to confirm.
macOS ships Vim with a protected system file at /usr/share/vim/vimrc and no user file. Create ~/.vimrc yourself and Vim will use it.
Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised