How does Vim handle writing .viminfo files? Does it simply append to an existing file, or does it delete and rewrite the file on disk every time Vim exits? Additionally, is this process consistent across different operating systems?
1 Answer
How does Vim handle writing .viminfo files?
Vim is open source. If you really wonder you are strongly advised to dig the code yourself.
Does it simply append to an existing file, or does it delete and rewrite the file on disk every time Vim exits?
The wording is misleading. Vim always creates a new file but the info from the old one may be merged. That depends on parameter of a command :h :wviminfo
. When Vim quits normally it does :wviminfo
, i.e. does merging.
Additionally, is this process consistent across different distributions of Vim?
This is too vague. Let's put it like this. Reading/writing viminfo file depends on some compilation features (e.g. FEAT_VIMINFO
), dedicated parameter settings (:h 'viminfo'
), and OS specifics (e.g. file permissions, attributes, etc.). But it should work okay across different Vim versions, sensitive parameters, such as :h 'encoding'
, etc.
Also, Neovim opts to use fully incompatible shada format instead of viminfo.
:h 'backupcopy'
. It explains in detail how files are written (which includes the viminfo file).