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 the ‘\’ (backslash) key before each key. This is the so-called ‘Leader’ key by default.

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" toggle syntax on/off
72nnoremap <expr> <Leader>s exists("syntax_on") ? ':syntax off<CR>' : ':syntax on<CR>'
73
74" toggle background light/dark
75nnoremap <expr> <Leader>l &background == 'light' ? ':set background=dark<CR>' : ':set background=light<CR>'
76
77" toggle listing of whitespace
78nnoremap <expr> <Leader>w ':set list!<CR>'
79
80" clear search highlight
81nnoremap <expr> <Leader>c ':noh<CR>'
82
83" insert date
84nnoremap <silent> <Leader>dd :put =strftime('%Y-%m-%d %a')<CR>
85
86" insert date and time
87nnoremap <silent> <Leader>dt :put =strftime('%Y-%m-%d %a, %H:%M')<CR>
88
89" insert complete date and time
90nnoremap <silent> <Leader>dT :put =strftime('%a, %d %b %Y %H:%M:%S %z')<CR>
91
92" toggle Goyo plugin
93nnoremap <expr> <Leader>G ':Goyo<CR>'
94
95" toggle Limelight plugin
96nnoremap <expr> <Leader>L ':Limelight!!<CR>'
97
98" toggle listing of whitespace
99nnoremap <silent> <expr> <Leader>w ':set list!<CR>'

Meta

Tags: vim, editor, plaintext, console, lightweight

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