6 ms·
Oh, and man… never ever let Vim write a backup file! They did that in the 70’s. Use modern ways for tracking your changes, for God’s sake. set nobackup set nos
by there 16y ago
Oh, and man… never ever let Vim write a backup file! They did that in the 70’s. Use modern ways for tracking your changes, for God’s sake.
set nobackup
set noswapfile
backup files are one thing, but turning off swap files is a terrible idea. vim can crash, you can accidentally close the window, your ssh session can die, etc. if you exit vim cleanly then the swap files will be transparent, so i don't see the point in disabling them.
- hasenj 16y agoso far, swap files have caused me more headache than anything else. I'm a paranoid maniac and I save every minute or two, so worst case I'll repeat a minute worth of coding. What really ends up happening is I try to edit a file and something annoying pops up telling me about something requiring my attention (swap file already exists .. read only mode .. bla bla). In other words, it's just a distraction, most of the time.
- gfodor 16y agoUntil it saves your ass. Which will happen, if you use vim for a few years. You can configure it to put your swap files in a canonical dir, instead of polluting the directory you're editing files in: set backupdir=/var/tmp,/tmp set directory=/var/tmp,/tmp Now you can just nuke the swap files in one swoop: rm -rf /var/tmp/*.swp
- jamesbritt 16y agoOr cron-job the pruning.
- bostonvaulter2 16y agoSwap files can save you from editing the same file in two vim instanstances as once. Possibly overwriting each other.
- jessor 16y agoor just do: set backupdir=./.backup,.,/tmp set directory=.,./.backup,/tmp This way, if you want your backups to be neatly grouped, just create a directory called '.backup' in your working directory. Vim will stash backups there. The 'directory' option controls where swap files go. If your working directory is not writable, Vim will put the swap file in one of the specified places. (http://vim.wikia.com/wiki/Remove_swap_and_backup_files_from_your_working_directory http://vim.wikia.com/wiki/Remove_swap_and_backup_files_from_...)
- parfe 16y agoset backupdir=~/.vim/backup// set directory=~/.vim/swp// The double tailing slash will store files using full paths so if you edit two different models.py files you won't clobber your swap or backups.
- davidu 16y agoOh man, this is awesome. Too bad it's vim-specific and not a shell built-in, which would be handy.
- EdiX 16y ago> vim can crash It can?
- there 16y agoyes, i've had it crash once in a rare while. Vim: Caught deadly signal SEGV
- IgorPartola 16y agoNever had vim crash, but I've had the OS crash. Or X server. Better safe than sorry.
- junkbit 16y agoScreen can help with the accidental closing of a window or a dropped ssh session. You can even restart X and just reattach to the daemon when you log back in.
- Vitaly 16y agothe minute I've read it I went and set the noswapfile option. I don't care if vim crashes, I save all the time. if it crashes I will just repeat the last edit. The stale swapfiles etc has caused me more time wasted over the years then lost edits. But, I soon realized that noswapfile has another problem which caused me to disable it after all: it will allow you to open same file in more then one vim editor instance. And this is really asking for troubles. It is less of a problem with graphical vim as you can use "autoread" to sync changes between instances, but it is a disaster on console.
- prasanmishra 16y agoI too very much happy after getting these two option. By looking those swap file and backup file I started hating vim. Why on earth it is creating all the un-necessary stuffs (though they useful at some case). Now for newbie like me I love this tips :)