19

Is there a way to source the ~/.config/nvim/init.vim file from within nvim?

With vanilla vim you can source .vimrc with :so % : Is there an equivalent method do with similarly in neovim?

alrob
  • 735
  • 1
  • 8
  • 16

3 Answers3

29

$MYVIMRC is always available from inside vim or neovim, so you can just use

:source $MYVIMRC

and bind it to a convenient mapping:

nnoremap <Leader>sv :source $MYVIMRC<CR>

2021 update: If you are using neovim with a lua config, you can use :luafile $MYVIMRC

alrob
  • 735
  • 1
  • 8
  • 16
5

How about use the map

let $my_vimrc = $localappdata.'\nvim\init.vim'
nnoremap <leader>s :source $my_vimrc<cr>
Carson
  • 6,105
  • 2
  • 37
  • 45
  • 1
    Thanks. I discovered that the variable $MYVIMRC is already set by default so you can just use that. – alrob Nov 02 '20 at 18:52
0

If you use Neovim you can do something like :

local bind = vim.keymap.set
bind("n", "<leader>s", ":source $HOME/.config/nvim/init.lua <CR>")

But it's not use with Lazy.nvim

Eliphaz Bouye
  • 21
  • 1
  • 4