How To Comment In vimrc (Vim Configuration) File?

As an advanced text editor, Vim has a lot of configuration options. These configuration options can be applied in different ways as temporary or permanent. The vimrc configuration file is used for permanent Vim configuration. While putting configurations inside the vimrc file we may need to write some comments in order to explain the given configuration.

Single Line Comment in vimrc (Vim Configuration) File

The vimrc or Vim configuration file uses the double quote for a single-line comment. A single quote at the start of the line will make this line a comment and not be interpreted as a configuration. If the single quote is not at the start of the line it will be interpreted as a configuration.

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

Also, comments are highlighted in the vimrc file like below which is different from regular configuration lines. The comments are colored blue and configuration statements are colors with different colors like yellow, white, green, etc.

Single Line Comment in vimrc (Vim Configuration) File

Multli Line Comments in vimrc (Vim Configuration) File

Multi-line comments are the same as single-line comments. Just put lines one after one like below.

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.

if has("syntax")
  syntax on
endif

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.

Leave a Comment