.vimrc
The .vimrc file is Vim’s main configuration file. It is read when Vim starts and controls editor behaviour, appearance, and custom shortcuts.
A .vimrc usually lives in your home directory:
~/.vimrc
On start-up, Vim executes the commands inside this file in order, exactly as if you typed them manually.
The goal of a good .vimrc is not to be large or clever. It should remove friction you actually feel while editing. This file grows over time as you discover things you want Vim to do differently.
Comments in .vimrc
In Vim script, comments start with a double quote “. Anything after ” on a line is ignored by Vim.
Example:
" This is a comment
set bg=dark " This is also a comment
The # character is not a comment character in Vim script. That is a shell convention, not a Vim one.
Current Configuration
At the moment, this .vimrc contains two settings. Both are simple, intentional, and commonly useful.
Background hintset bg=dark
This tells Vim that the terminal or GUI background is dark.
Vim uses this information to adjust syntax highlighting and UI contrast. It does not select a colour scheme by itself. It only influences how colours are interpreted.
If you later switch to a light terminal theme, this should be changed to:
set bg=light
Bash shebang abbreviationabbr _sh #!/bin/bash
This defines an abbreviation. When you type _sh in Insert mode and then press a word boundary key like Space or Enter, Vim automatically expands it to: !/bin/bash
Important details:
- Abbreviations only expand in Insert mode
- They trigger only after a completed word
- They do not affect Normal mode commands
Current .vimrc File
" Assume a dark terminal background for correct highlighting
set bg=dark
" Abbreviation for quickly inserting a bash shebang
abbr _sh #!/bin/bashVimLNotes Going Forward
This configuration is intentionally small. As Vim usage grows, typical additions include:
- Line numbering
- Indentation and tab behaviour
- Key mappings
- Filetype-specific settings
