1

I'm a beginner at Vim. I have downloaded the latest version of Vim on my Windows 7 system.

I attempted to open and save an existing .txt file after making a minor change and got some interesting behavior which I would like help understanding.

I have a file named "Python_Link.txt" on my desktop. I opened Vim and typed the following on Normal Mode:

:e C:\Users\Joe\Desktop\Python_Link.txt

When I press Enter the file opens as I would expect in Vim.

I then type:

o

in Normal Mode. This works as expected. I then type in some lines of text. I then press:

esc

I'm back in Normal Mode. I then enter:

:w

I then manually close Vim by terminating it by clicking on the X in the upper right hand corner of the window.

When I check back on my desktop I now have 3 files instead of the one I originally started with. The one I started with appears unchanged when I open it in Windows Notepad. When I open one of the other files I see the changes I made in Vim exactly as I made them. The 3rd file looks like it contains Binary data, but the first 3 characters are "Vim"

When I open a Console and navigate to the desktop and use the

dir

command I see the following 3 files listed:

Python_Link.txt Python_Link.txt~ .Python_Link.txt.un~

The .txt~ file contains my original data. The .txt file contains the original data and the changes I added in Vim. The .un~ file contains the data which looks like Binary data.

I was under the impression that the :w Command in Normal Mode in Vim merely saved the file. That's what I was trying to do. Can someone please explain what is happening? Thanks in advance.

0

The .txt~ file is a standard vim backup file. To stop vim from creating one, add the following to your _vimrc:

set nobackup
set nowritebackup

According to this question on SO, the .un~ is an undo file. It can be turned off by the following command in your _vimrc:

set noundofile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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