0

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?

5
  • Vim's source code is that way.
    – romainl
    Commented Jul 6 at 20:53
  • Could you clarify what you mean with "different distributions"? Do you mean Vim and Neovim? I also don't see how your question would make a difference to a Vim user. Does it matter how viminfo was written as long as it was written? What's the specific problem you*re trying to solve?
    – Friedrich
    Commented Jul 6 at 21:21
  • When talking about different distributions, I'm referring to different operating systems. Commented Jul 19 at 0:13
  • Thanks for the edit. I still have a hard time understanding the motivation for this question. In what ways did Matt's answer below not address it? I voted to close as "needs details or clarity"
    – Friedrich
    Commented Jul 19 at 7:22
  • 1
    Please have also a look at :h 'backupcopy'. It explains in detail how files are written (which includes the viminfo file). Commented Jul 19 at 11:44

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.