How to Change Vim Config in .vimrc Without Leaving Vim

The aim of this page📝 is to explain how to configure and use Vim based on the particular example of enabling syntax highlighting and working with the .vimrc file. I know it's really for beginners, but it is so easy to change settings.json in VSCODE and have the config reloaded right away that knowing a few steps to achieve that in Vim is quite useful, too.

Pavol Kutaj
1 min readDec 10, 2023

UPDATE: My notes below are more of an explanation of the mechanics. The canonical way is I believe in the great episode of the great Vimcast series http://vimcasts.org/episodes/updating-your-vimrc-file-on-the-fly/

  • One of the important aspects of configuring Vim is the .vimrc file.
  • .vimrc is a configuration file for Vim.
  • It is used to set various settings and enable features in Vim.
  • As an example, syntax highlighting is one of the features that can be enabled in Vim.
  • Syntax highlighting in Vim can be enabled by adding syntax on in the .vimrc file.
  • The .vimrc file can be opened directly from Vim using the command :e $MYVIMRC.
  • After making changes to the .vimrc file, you save the changes, return back to the original file and can reload it without leaving Vim using the command :source $MYVIMRC.

COMMAND

" Open .vimrc file from Vim
:e $MYVIMRC

" Enable syntax highlighting
syntax on

" Save
:w

" Return to the previously opened file
:e#

" Reload .vimrc file without leaving Vim
:so $MYVIMRC

--

--

No responses yet