Can T Write Viminfo File Windows

Active1 month ago

I'm afraid I've run into something rather strange. When I open a file normally, vim README.txt, everything is fine. But upon sudo vim README.txt, the file renders blank, and gives me a E138: Can't write viminfo file $HOME/.viminfo! error upon trying to exit.

E886: Can't rename viminfo file to /home/kjeld/.viminfo! Ask Question 1. I have started to use a ubuntu 16.04 server, and set it up exactly the same way as my 14.04 servers (and conceptually like my 10.04 and 12.04 servers). Don't have write privileges in Rstudio using Ubuntu 16.04. Firefox can only be started by sudo. The viminfo file * viminfo* * viminfo-file* * E136* * E575* * E576* * E577* If you exit Vim and later start it again, you would normally lose a lot of information. The viminfo file can be used to remember that information, which enables you to continue where you left off. Three questions about Vim. Can't write viminfo file C: _viminfo! MyUserName, everything is just fine, and a file named viminfo is created under this directory. So why does it do this? Can’t Vim create this viminfo file under C:, just as it does in C: Users MyUserName? Windows file vim command-line directory.

I suspected the .viminfo file was corrupt, so I deleted it. This problem remains. Can anyone help?

Gilles
572k138 gold badges1182 silver badges1693 bronze badges

Can't Rename Viminfo File

James Adam BucklandJames Adam Buckland

9 Answers

When you run sudo vim you start vim as root. That means that it is the viminfo file in /root that is the problem. You should do rm /root/.viminf*.

To make sure of this, run sudo vim and execute this command: :!echo $HOME.This will show you that your home directory is /root.

I would recommend that you do not run vim as root, but rather use sudoedit. This is a more secure solution as the editor is not running as root. You never know what a plugin might do. Additionally it allows you to use your own settings and plugins in vim and not the ones in roots vimrc. sudoedit is the same as running sudo -e. sudoedit works by making a temporary copy of the file that is owned by the invoking user (you). When you finish editing, the changes are written to the actual file and the temporary file is deleted.

As a general rule of thumb: Do not run things as root if it is not necessary.

Rui F Ribeiro
41.3k16 gold badges94 silver badges158 bronze badges
arnefmarnefm

I got this error on every exit. I did not use sudo. It explicitly mentioned my user home directory:

Removing ~/.viminfo did not fix the error.

Turns out I had a bunch of viminfo temp files, and removing those fixed the issue:

Found this solution here.

Henrik NHenrik N

I received the same error when trying to :wq a file on a disk that was completely full. If you receive this message, you may wish to check your available disk space.

duhaimeduhaime

A much more cleaner way to create a home directory would be to use the skeleton that linux provides for you for example.

RickE138 can t write viminfo fileRick
1,2171 gold badge6 silver badges5 bronze badges

For me the issue was that I had changed my home directory to location inside an NFS mount. For some reason, this resulted in the owner of the directory to be 'nobody'. Adding write permissions for 'other' solved the problem as I was clearly not the owner of the file.

Can T Write Viminfo File Windows
Jon DeatonJon Deaton

Most likely this is happening because the home dir has run out of disk space and any new vim operation is unable to write in the .viminfo file.

psglinuxpsglinux

I had the same issue when updating the content of Makefile. I needed a local variable and decided to name it HOME, so I entered the line HOME=2.154. This causes the vim-HOME setting to be replaced by a non-existing directory. Don't use the HOME variable for other use.

user191855user191855

I think this may only apply to pretty old versions of linux/vi but what I found was that there were temporary files in the root's home directory with the filenames /root/.viminfa.tmp ... /root/.viminfz.tmp and that there were 26 of them with timestamps covering several years. We had run out of letters of the alphabet as all of a-z were taken. I removed all of those files and the problem dissappeared.Of course Henrik's# rm -rf ~/.viminf*would fix this problem just fine.

Stephen EdgeStephen Edge

It seems like you have cleared environment variables.

Do this:

export HOME=/root

This should resolve your issue.

AshfaqAshfaq

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

Active1 month ago

E138: can't write to viminfo file C:Windowssystem32configsystemprofile_viminfo!

but I don't find the file from C:Windowssystem32configsystemprofile_viminfo! It also can't find .viminf*.tmp anywhere.

fuhao715fuhao715

migrated from stackoverflow.comDec 19 '12 at 10:11

This question came from our site for professional and enthusiast programmers.

3 Answers

If you are launching gvim via a taskbar shortcut you end up using system32 as what would usually be expected as a user's home folder. To check, right-click the taskbar vim icon and go to properties and see where it is launching from.

You may want to manually set it to your user directory. THEN things like viminfo _vimrc etc work as expected.

Also, remember that .vimrc (with the dot) is what the file is in unix or mac but use underscore for windows : _vimrc. I would assume that this behavior would carry over to other files as well, ie. viminfo. The underscore is the hiding char equivalent to the dot -- I think... it's been a while since I the windows.

dustydusty

This is probably an auth issue. Try creating $HOME/_viminfo manually.

romainl

Can T Write Viminfo File Root Viminfo

romainl

Can T Write Viminfo File Windows 7

18.6k2 gold badges34 silver badges46 bronze badges
E138 can t write viminfo file

The accepted answer here is correct.Changing Vim Home Directory

Turns out all I had to do was set the HOME environment variable.I set it to the same as ~

so in your powershell $profile file (if that's is your thing)

SteveSteve

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