Notes on the Vim text editor

by Jochem Kossen on

english, tech

In search of a calm editor with few distractions, I made a configuration for the Vim (and Vim Classic) text editor. While some don’t consider Vim to be an editor with low cognitive load, I humbly disagree with this. Yes it has a learning curve, but it’s well documented, and you can learn basic functionality very quickly. Also, the basic use of Vim does not change much, so everything you learn is knowledge you’ll be able to use for decades.

TLDR: You can get the configuration (.vimrc) at #Configuration

If you desire an even lighter weight text editor, take a look at my Notes on the nvi text editor.

Note: In march 2026, a new fork of Vim called Vim Classic was launched by Drew Devault. This fork does not and will not accept generative AI / LLM driven commits.

In the words of Drew:

“Vim Classic is a fork of Vim 8.x for long-term maintenance, providing a stable, dependable editor — maintained entirely by humans.”

Sounds perfect for my use. The current ‘official’ Vim is at 9.x, but my config below works fine with both Vim 9.x and Vim Classic 8.3, which is what I currently use.

Features

Keyboard shortcuts

Use these in ’normal’ mode. Press SPACE before each key.

Key    Action
cClear search highlight
lToggle dark / light background
sToggle syntax highlighting
ddInsert date
dtInsert date and time
dTInsert more complete date and time
GToggle the Goyo plugin (center your text)
LToggle the Limelight plugin (highlight current paragraph, darken others)
wToggle listing of whitespace characters

A few tips on using Vim

Vim offers a lot of shortcuts for functionality to help you edit conveniently and fast. But you don’t need to remember them all. I don’t. Here are a few I do use regularly and which seem to stick in my mind.

Key      Action
{Move cursor to before current paragraph
}Move cursor to after current paragraph
/ForeMove cursor to next occurrence of 'Fore'
?BackMove cursor to previous occurrence of 'Back'
nMove cursor to next match of previous search term
ggMove cursor to beginning of file
GMove cursor to end of file
:42Move cursor to line 42
y4lYank (copy) the next 4 characters starting from the cursor
y4yYank (copy) 4 lines starting from the cursor
pPaste yanked contents after current line
PPaste yanked contents before current line
ciwReplace word (think Change In Word)
ci(Change next text between ()
ci<Change next text between < and > (think HTML tags)
dapDelete a (current) paragraph
uundo (multiple u for multiple undo)
Ctrl-rredo
~Change case of selection
.Repeat last modification action

Screenshots

Below are some screenshots of how this configuration of Vim looks. Click on them to see a larger version. I mostly have Limelight and syntax disabled, and use Vim full screen. So my screen usually looks like something resembling the first screenshot.

Configuration

vim uses a file called .vimrc in your home folder.

Download this file and save it as .vimrc in your home folder. Then customize it to your heart’s desire! :-)

=> vimrc.txt

Contents:

  1" vi compatibility
  2set nocompatible
  3
  4" locale
  5language en_US.UTF-8
  6
  7" Encoding
  8set encoding=utf-8
  9
 10" true color support
 11set termguicolors
 12
 13" Color scheme (terminal)
 14set t_Co=256
 15
 16" Syntax highlighting
 17syntax off
 18
 19" Blink cursor on error instead of beeping (grr)
 20set visualbell
 21
 22" How many lines of command history to remember?
 23set history=1000
 24
 25" Show status line
 26set laststatus=2
 27
 28" Show menu for completion
 29set wildmenu
 30
 31" Show cursor position
 32set ruler
 33
 34" Reread file changed outside vim
 35set autoread
 36
 37" Delete comment character when joining commented lines
 38set formatoptions+=j
 39
 40" Wrapping
 41set wrap
 42" Wrap at word boundary
 43set lbr
 44
 45" Whitespace
 46set textwidth=0
 47set formatoptions=tcqrn1
 48set tabstop=8
 49set shiftwidth=8
 50set softtabstop=8
 51set noexpandtab
 52set noshiftround
 53set smarttab
 54
 55" How to indicate whitespace
 56set listchars=tab:⟶\ ,trail:▸,extends:⟶,precedes:⟵,nbsp:+
 57
 58" Incremental search
 59set incsearch
 60
 61" Highlight search
 62set hlsearch
 63
 64" For plugins to load correctly
 65filetype plugin indent on
 66
 67" limelight
 68let g:limelight_conceal_ctermfg = 'gray'
 69let g:limelight_conceal_ctermfg = 240
 70
 71" Use space for keyboard shortcuts
 72nnoremap <SPACE> <Nop>
 73let mapleader=" "
 74
 75" toggle syntax on/off
 76nnoremap <expr> <Leader>s exists("syntax_on") ? ':syntax off<CR>' : ':syntax on<CR>'
 77
 78" toggle background light/dark
 79nnoremap <expr> <Leader>l &background == 'light' ? ':set background=dark<CR>' : ':set background=light<CR>'
 80
 81" toggle listing of whitespace
 82nnoremap <expr> <Leader>w ':set list!<CR>'
 83
 84" clear search highlight
 85nnoremap <expr> <Leader>c ':noh<CR>'
 86
 87" insert date
 88nnoremap <silent> <Leader>dd :put =strftime('%Y-%m-%d %a')<CR>
 89
 90" insert date and time
 91nnoremap <silent> <Leader>dt :put =strftime('%Y-%m-%d %a, %H:%M')<CR>
 92
 93" insert complete date and time
 94nnoremap <silent> <Leader>dT :put =strftime('%a, %d %b %Y %H:%M:%S %z')<CR>
 95
 96" toggle Goyo plugin
 97nnoremap <expr> <Leader>G ':Goyo<CR>'
 98
 99" toggle Limelight plugin
100nnoremap <expr> <Leader>L ':Limelight!!<CR>'
101
102" toggle listing of whitespace
103nnoremap <silent> <expr> <Leader>w ':set list!<CR>'

Meta

Tags: vim, editor, plaintext, console, lightweight

Permalink: https://jkossen.nl/vim/