如何使 vimrc 更改在 Neovim 上永久生效

how to make vimrc changes permanent on Neovim

我是 nvim 编辑器的新手。我需要帮助来设置我的 ~/.vimrc 文件。我看过一些教程并遵循了它们。想出了这个:

> vim ~/.vimrc

已将此添加到我的 vimrc.

syntax on

set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nu

然后获取文件

:source %

更改会立即应用。但是当我退出文件并再次打开它时,更改消失了。如果我再次采购它,它就会起作用。有什么方法可以使这些更改永久化。
[注意]:当我退出我使用的文件时 :x
更新:
当我尝试使用 vim 打开 ~/.config/nvim/init.vim 时。我收到这个错误。

E325: ATTENTION
Found a swap file by the name "~/.local/share/nvim/swap//%home%manoj%.config%nvi
m%init.vim.swp"
          owned by: manoj   dated: Wed Mar 31 16:01:46 2021
         file name: ~manoj/.config/nvim/init.vim
          modified: YES
         user name: manoj   host name: manoj
        process ID: 15099
While opening file "/home/manoj/.config/nvim/init.vim"
      CANNOT BE FOUND
(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /home/manoj/.config/nvim/init
.vim"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/home/manoj/.local/share/nvim
/swap//%home%manoj%.config%nvim%init.vim.swp"
    to avoid this message.

Swap file "~/.local/share/nvim/swap//%home%manoj%.config%nvim%init.vim.swp" alre
ady exists!

~/.vimrc 是 vim 的默认配置文件。对于 neovim,只需将文件复制到 ~/.config/nvim/init.vim(您可能需要先创建 nvim 目录)。

摘自 arch wiki, although the most info is in the official documentation.