This is a card in Dave's Virtual Box of Cards.

Vim: Loading defaults.vim

Page created: 2026-02-16

In OpenBSD, I noticed I wasn’t getting some of the default Vim behavior I expect, such as remembering the last cursor position when opening a file.

After a bit of searching, I learned about the defaults.vim file. You can read about it with:

:help defaults

(Which opens Vim’s starting.txt doc at the "Defaults without a .vimrc file" section.)

You can view the defaults file with:

:e $VIMRUNTIME/defaults.vim

It contains the cursor position auto-command, which starts with this comment:

" When editing a file, always jump to the last known cursor position.

As the help file mentions, you can have these defaults loaded by putting these lines near the top of your own vimrc:

unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim

Which is exactly what I did and it worked!

By the way, you can view the vimrc file locations, among other useful info, with:

:version