vim: how to stop vim from generating ANY additional files?

248 views
Skip to first unread message

ping

unread,
Feb 16, 2013, 10:01:10 PM2/16/13
to vim...@googlegroups.com
the question is in the subject, I've been with VIM daily for quite a
while and I normally is OK with it.
but I just reallized it's not good if I generate a lot of additional
files when I change some config file in my linux FS.
typically they are sth like:

asciidoctips.txt~
.asciidoctips.txt.un~

.pers-notes.txt.swh
.pers-notes.txt.swi
.pers-notes.txt.swj
.pers-notes.txt.swk
.pers-notes.txt.swl
.pers-notes.txt.swm
.pers-notes.txt.swn
.pers-notes.txt.swo
.tech-tips2.txt.swp

just want to confirm, to make sure there is not a single additonal file
generated by vim under all circumstances, are following settings sufficient?

set nobackup
set noudf

thanks!

John Little

unread,
Feb 16, 2013, 10:54:03 PM2/16/13
to vim...@googlegroups.com
On Sunday, February 17, 2013 4:01:10 PM UTC+13, ping wrote:
> typically they are sth like:
>
> asciidoctips.txt~
> .asciidoctips.txt.un~
Those are backup files. The file you are editing is renamed to something like this before the new version is written.


> .pers-notes.txt.swh
> .pers-notes.txt.swi
> .pers-notes.txt.swj
> .pers-notes.txt.swk
> .pers-notes.txt.swl
> .pers-notes.txt.swm
> .pers-notes.txt.swn
> .pers-notes.txt.swo
> .tech-tips2.txt.swp

Those are all swap files. The fact that there are many for .pers-notes.txt implies that vim has been killed or crashed a lot. Normally, swap files are deleted when vim exits cleanly.

> just want to confirm, to make sure there is not a single additonal file
> generated by vim under all circumstances, are following settings sufficient?
>
> set nobackup
> set noudf

In principle, you'd want set noswf as well, but I think your approach is ... well, would "foolhardy" be acceptable? Perhaps "risky" is better. These backup and swap files protect against losing your files. One doesn't need them often, but I've been very glad on several occasions. Undo files are off by default.

You shouldn't be getting stray swap files, it's much preferable to work out why vim is dying and fix it. Note that after vim does die, on the next restart vim warns you about the problem but is reluctant to delete the file, you may have to manually delete it.

Backup files are IMO better tamed using the backupdir option to put them in a central place.

Regards, John Little

ping

unread,
Feb 17, 2013, 9:30:32 AM2/17/13
to vim...@googlegroups.com, John Little
On 2/16/2013 10:54 PM, John Little wrote:
> In principle, you'd want set noswf as well, but I think your approach is ... well, would "foolhardy" be acceptable? Perhaps "risky" is better. These backup and swap files protect against losing your files. One doesn't need them often, but I've been very glad on several occasions. Undo files are off by default.
>
> You shouldn't be getting stray swap files, it's much preferable to work out why vim is dying and fix it. Note that after vim does die, on the next restart vim warns you about the problem but is reluctant to delete the file, you may have to manually delete it.
I understood, thanks for reminding.
I won't turn them off in my daily work.
but I just want to have a quick/neat way to turn them off in SOME
scenarios .
so my current method is to define following map

"no additonal files
nn ,nf <esc>:set nobackup<CR>:set noudf<CR>:set noswp<CR>

so right after I started a new vim before I open any system config file,
I quickly type ",nf" to turn off any additional file generations.
>
> Backup files are IMO better tamed using the backupdir option to put them in a central place.
this looks good, but what if you have 2 files from different folders
sharing the same name?

tooth pik

unread,
Feb 17, 2013, 12:00:44 PM2/17/13
to vim...@googlegroups.com
that isn't a problem for 'backupdir' -- it munges a swapfile name that
includes the path

sc

ping

unread,
Feb 17, 2013, 12:47:26 PM2/17/13
to vim...@googlegroups.com, tooth pik
really? this is cool then.
I'm thinking to give it a trial.

thanks!
regards
ping

John Little

unread,
Feb 17, 2013, 3:48:40 PM2/17/13
to vim...@googlegroups.com, John Little
On Monday, February 18, 2013 3:30:32 AM UTC+13, ping wrote:
> nn ,nf <esc>:set nobackup<CR>:set noudf<CR>:set noswp<CR>

That last word should be "noswf".
I presume that's a typo, or you'd get an error message.

Regards, John

ping

unread,
Feb 17, 2013, 9:32:52 PM2/17/13
to vim...@googlegroups.com, John Little
yes its typo, thanks!
Reply all
Reply to author
Forward
0 new messages