Search code examples
vimvineovim

how to make vimrc changes permanent on Neovim


I am new to nvim editor. i need help setting up my ~/.vimrc file. i have seen some tutorials and followed them. and came up with this:

> vim ~/.vimrc

have added this to my vimrc.

syntax on

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

and then source the file

:source %

the changes get applied instantly. but when i exit the file and open it again the changes disappear. if i source it again it works. is there any way i can make these changes permanent.
[note] : when i exit the file i used :x
UPDATE:
when i try to open ~/.config/nvim/init.vim using vim. i am getting this error.

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!

Solution

  • ~/.vimrc is the default configuration file for vim. For neovim, simply copy the file to ~/.config/nvim/init.vim (You may need to create the nvim directory first).

    Taken from the arch wiki, although the most info is in the official documentation.