Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a .un~ file or or why does Vim in the Terminal make the .un~ file?

I've noticed I have some dotfiles that end with .un~, for example I have a .vividchalk.vim.un~, but I'm not sure where that came from. It seems like they are created when I use Vim in the Terminal. What are these files? Can have them remove themselves when I close the file I'm editing?

like image 378
kaplan Avatar asked Mar 27 '13 13:03

kaplan


People also ask

What is un file Vim?

When you edit and save files, Vim creates a file with the same name as the original file and an un~ extension at the end. Vim 7.3 contains a new feature persistent undo, that is, undo information won't be lost when quitting Vim and be stored in a file that ends with .un~ .


3 Answers

When you edit and save files, Vim creates a file with the same name as the original file and an un~ extension at the end.

Vim 7.3 contains a new feature persistent undo, that is, undo information won't be lost when quitting Vim and be stored in a file that ends with .un~. You have set the undofile option, so Vim creates an undo file when saving the original file. You can stop Vim from creating the backup file, by clearing the option:

:set noundofile

Note that, by default this option is turned off. You have explicitly enabled the undofile option in one of the initialization files. If you want your undofiles to be stored only in a particular directory, you can point the undodir option to a directory that will contain all your aggregated undofiles.

Source: http://vimhelp.appspot.com/vim_faq.txt.html#faq-7.2

like image 169
TheEwook Avatar answered Oct 19 '22 15:10

TheEwook


Took me a while to find where to actually put the :set noundofile command. I am new and I’ll just reply with how I made it not do backups.

  1. Open vim.
  2. Type in command mode :e $HOME/.vimrc
  3. Write :set noundofile
  4. Save & quit: :wq
like image 39
Spiros Skouras Avatar answered Oct 19 '22 16:10

Spiros Skouras


Another possible way to avoid vim creating undo files everywhere is set set the undodir to some existing directory, e.g.

if has('persistent_undo')         "check if your vim version supports
  set undodir=$HOME/.vim/undo     "directory where the undo files will be stored
  set undofile                    "turn on the feature
endif

snagged from here

like image 8
Brad Parks Avatar answered Oct 19 '22 17:10

Brad Parks