Prevent vim from polluting the file system with a bunch of temporary $HOME/.viminf[a-z] files

378 views
Skip to first unread message

Chris Jones

unread,
Jun 30, 2021, 7:46:38 PM6/30/21
to vim...@googlegroups.com
No idea where these files come from or what they're for. I ended up
grepping the reference manual for clues and am none the wiser. Internet
searches also failed to give me an answer.

Is there any way to tell vim NOT to create them in the first place?

Thanks,

CJ

Gary Johnson

unread,
Jun 30, 2021, 9:29:16 PM6/30/21
to vim...@googlegroups.com
It looks like the :wviminfo command will write those. See

:help :wv

Unfortunately, I couldn't find any explanation of why "old temp
files [would be] left behind", nor any other reference to "viminf*".

I looked in the source, viminfo.c. From a quick read, it looks like
Vim creates a temporary file with a name like that and uses it to
build the viminfo file. When Vim finishes building that file, it
renames it to the default ~/.viminfo or whatever name the user has
chosen via the -i command-line option or the 'viminfo' or
'viminfofile' options.

If that rename fails, Vim prints an error message and tries to
delete the temporary file.

The best way to avoid having those files laying around is to find
out why Vim is unable to rename them and fix that problem. Watch
for error messages when Vim closes.

HTH,
Gary

aro...@vex.net

unread,
Jul 1, 2021, 9:37:41 AM7/1/21
to vim...@googlegroups.com

> The best way to avoid having those files laying around is to find
> out why Vim is unable to rename them and fix that problem. Watch
> for error messages when Vim closes.
>

Possibly a permissions problem? A look at the permissions and ownership of
the files and the containing directory might offer some clues.

Chris Jones

unread,
Jul 3, 2021, 1:51:32 PM7/3/21
to vim...@googlegroups.com
According to the vim help (help wv):

When you get error "E929: Too many viminfo temp files"
check that no old temp files were left behind (e.g.
~/.viminf*) and that you can write in the directory of
the .viminfo file.

I would imagine I can write to my $HOME directory...?

As to ownership I was in the middle of some sticky issue and I deleted
the files as suggested by the E929: error message (instead of moving
them to some safe place or other) so I cannot verify that but I would
also imagine that I am/was the owner thereof.

I have a feeling this may have to do to with my having had a series of
lockups lately where the only option was ssh'ing to the box and issuing
'shutdown -r now' commands as the only way out. Tried to recreate the
situtation but haven't had any luck so far.

One possible work around would be to direct the files to /tmp (or
a subdirectory of /tmp) rather than my home directory where they would
be taken care of when the machine is restarted but I haven't found a way
to persuade vim do just that. Shouldn't /tmp/... be the place where temp
files are created?

Anyway, now I have at least a vague idea of what these files are for so
I'll stop worrying and live with it.

Thanks,

CJ

John Barbour

unread,
Jul 5, 2021, 7:33:43 AM7/5/21
to vim...@googlegroups.com
Side note, a "tmux" or "screen" session can helpful when network
connectivity is and issue.

Chris Jones

unread,
Jul 5, 2021, 6:53:26 PM7/5/21
to vim...@googlegroups.com
On Mon, Jul 05, 2021 at 07:10:40AM EDT, John Barbour wrote:

> Side note, a "tmux" or "screen" session can helpful when network
> connectivity is and issue.

I think that what may have caused the problem is that due to having had
to move all my stuff to a new box and restore from backups... which
meant compatibility issues with the new hardware (older kernels mostly)
I've had to live in unstable conditions for aabout a month with
lockups... etc. so that my vim sessions were brutally interrupted as
a matter of course. That may explain how so many of those .viminf[a-z]
files were left behind...

I haven't had any of those show up since. Not one.

But shouldn't vim alert the user to the presence of such files since
they appear to be a symptom that something is amiss?

Instead vim appears to silently/happily carry on creating new temp
files... without doing anything with the old ones until it runs out of
letters (options).

Doesn't sound right to me...

CJ
Reply all
Reply to author
Forward
0 new messages