Why does Vim save files with a ~ extension?
up vote
160
down vote
favorite
I've found that while using Vim on Windows Vim saves the file, a .ext.swp file that's deleted on closing the Vim window and a .ext~ file.
I assume the .ext.swp file is a session backup in case Vim crashes. What's the purpose of the .ext~ file however? Is this a permanent backup file? It's annoying as I'd like to copy all the files I'm working on to my host, without these duplicates. How can I turn this off or, if it's there for a good reason, hide the files?
vim
add a comment |
up vote
160
down vote
favorite
I've found that while using Vim on Windows Vim saves the file, a .ext.swp file that's deleted on closing the Vim window and a .ext~ file.
I assume the .ext.swp file is a session backup in case Vim crashes. What's the purpose of the .ext~ file however? Is this a permanent backup file? It's annoying as I'd like to copy all the files I'm working on to my host, without these duplicates. How can I turn this off or, if it's there for a good reason, hide the files?
vim
Do you have any file open simultaneously in more than one place, they will create a.ext.swp.
– dirkgently
Mar 3 '09 at 18:00
1
dirkgently: No, on here I can open a file in the only vim window and it will create the .swp file. I'm not too fussed about that as it's removed when I save/close the window.
– Ross
Mar 3 '09 at 18:02
add a comment |
up vote
160
down vote
favorite
up vote
160
down vote
favorite
I've found that while using Vim on Windows Vim saves the file, a .ext.swp file that's deleted on closing the Vim window and a .ext~ file.
I assume the .ext.swp file is a session backup in case Vim crashes. What's the purpose of the .ext~ file however? Is this a permanent backup file? It's annoying as I'd like to copy all the files I'm working on to my host, without these duplicates. How can I turn this off or, if it's there for a good reason, hide the files?
vim
I've found that while using Vim on Windows Vim saves the file, a .ext.swp file that's deleted on closing the Vim window and a .ext~ file.
I assume the .ext.swp file is a session backup in case Vim crashes. What's the purpose of the .ext~ file however? Is this a permanent backup file? It's annoying as I'd like to copy all the files I'm working on to my host, without these duplicates. How can I turn this off or, if it's there for a good reason, hide the files?
vim
vim
edited Mar 3 '09 at 20:52
asked Mar 3 '09 at 17:56
Ross
29k33103166
29k33103166
Do you have any file open simultaneously in more than one place, they will create a.ext.swp.
– dirkgently
Mar 3 '09 at 18:00
1
dirkgently: No, on here I can open a file in the only vim window and it will create the .swp file. I'm not too fussed about that as it's removed when I save/close the window.
– Ross
Mar 3 '09 at 18:02
add a comment |
Do you have any file open simultaneously in more than one place, they will create a.ext.swp.
– dirkgently
Mar 3 '09 at 18:00
1
dirkgently: No, on here I can open a file in the only vim window and it will create the .swp file. I'm not too fussed about that as it's removed when I save/close the window.
– Ross
Mar 3 '09 at 18:02
Do you have any file open simultaneously in more than one place, they will create a
.ext.swp.– dirkgently
Mar 3 '09 at 18:00
Do you have any file open simultaneously in more than one place, they will create a
.ext.swp.– dirkgently
Mar 3 '09 at 18:00
1
1
dirkgently: No, on here I can open a file in the only vim window and it will create the .swp file. I'm not too fussed about that as it's removed when I save/close the window.
– Ross
Mar 3 '09 at 18:02
dirkgently: No, on here I can open a file in the only vim window and it will create the .swp file. I'm not too fussed about that as it's removed when I save/close the window.
– Ross
Mar 3 '09 at 18:02
add a comment |
9 Answers
9
active
oldest
votes
up vote
205
down vote
accepted
The *.ext~ file is a backup file, containing the file as it was before you edited it.
The *.ext.swp file is the swap file, which serves as a lock file and contains the undo/redo history as well as any other internal info Vim needs. In case of a crash you can re-open your file and Vim will restore its previous state from the swap file (which I find helpful, so I don't switch it off).
To switch off automatic creation of backup files, use (in your vimrc):
set nobackup
set nowritebackup
Where nowritebackup changes the default "save" behavior of Vim, which is:
- write buffer to new file
- delete the original file
- rename the new file
and makes Vim write the buffer to the original file (resulting in the risk of destroying it in case of an I/O error). But you prevent "jumping files" on the Windows desktop with it, which is the primary reason for me to have nowritebackup in place.
7
+1 Foryou prevent "jumping files" on the Windows desktop. Googled and found this answer
– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
1
Actually - do I have to have bothnobackupandnowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?
– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
@Merlyn: If you havebackup(as opposed tonobackup), then Vim will create a backup (the*.ext~file). This is completely unrelated tonowritebackup.
– Tomalak
Mar 28 '11 at 22:26
5
There is a table describing different behavior between combination of those switches:help backup-table. It turns out setting neithernobackupnornowritebackup, but instead settingbackupcopy=yesalso solves the "jumping" problem. This may hurt perf, though, so to each their own
– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
24
Instead of turning off , backup to a directoryset backupdir=~/.vim/backupin .vimrc or _vimrc on windows
– tsukimi
Dec 5 '13 at 1:10
|
show 1 more comment
up vote
199
down vote
I think the better solution is to place these lines in your vimrc file
set backupdir=~/vimtmp,.
set directory=~/vimtmp,.
You have to create a directory in your home directory called vimtmp for this to work.
That way you get the benefit of both worlds, you don't have to see the files, but if something does get futzed you can go get your backup file from vimtmp. Don't forget to clean the directory out every now and then.
19
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
10
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
7
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
2
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
11
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
|
show 8 more comments
up vote
23
down vote
To turn off those files, just add these lines to .vimrc (vim configuration file on unix based OS):
set nobackup #no backup files
set nowritebackup #only in case you don't want a backup file while editing
set noswapfile #no swap files
add a comment |
up vote
12
down vote
:set nobackup
will turn off backups. You can also set a backupdir if you still want those backup files but in a central folder. This way your working dir is not littered with ~ files.
You find more information on backups under :he backup.
add a comment |
up vote
11
down vote
And you can also set a different backup extension and where to save those backup (I prefer ~/.vimbackups on linux). I used to use "versioned" backups, via:
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'
This sets a dynamic backup extension (ORIGINALFILENAME-YYYYMMDD-HHMMSS.vimbackup).
3
you might want to include how to set up the back up directory, i.e. puttingset backupdir=~/.vimbackupsin your ~/.vimrc
– rampion
Mar 3 '09 at 22:30
1
The vim help fully describes this technique. See:help backupext
– netjeff
Jun 9 '11 at 19:05
add a comment |
up vote
6
down vote
You're correct that the .swp file is used by vim for locking and as a recovery file.
Try putting set nobackup in your vimrc if you don't want these files. See the Vim docs for various backup related options if you want the whole scoop, or want to have .bak files instead...
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
add a comment |
up vote
5
down vote
Put this line into your vimrc:
set nobk nowb noswf noudf " nobackup nowritebackup noswapfile noundofile
In Windows that would be the C:Program Files (x86)vim_vimrc file for system-wide vim configuration for all users.
Setting the last one noundofile is important in Windows to prevent the creation of *~ tilda files after editing.
I wish Vim had that line included by default. Nobody likes ugly directories.
Let the user choose if and how she wants to enable advanced backup/undo file features first.
This is the most annoying part of Vim.
The next step is to set up set noeb vb t_vb= to disable beeping :P
add a comment |
up vote
4
down vote
The only option that worked for me was to put this line in my ~/.vimrc file
set noundofile
The other options referring to backup files did not prevent the creation of the temp files ending in ~ (tilde)
add a comment |
up vote
0
down vote
I had to add set noundofile to ~_gvimrc
The "~" directory can be identified by changing the directory with the cd ~ command
add a comment |
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
205
down vote
accepted
The *.ext~ file is a backup file, containing the file as it was before you edited it.
The *.ext.swp file is the swap file, which serves as a lock file and contains the undo/redo history as well as any other internal info Vim needs. In case of a crash you can re-open your file and Vim will restore its previous state from the swap file (which I find helpful, so I don't switch it off).
To switch off automatic creation of backup files, use (in your vimrc):
set nobackup
set nowritebackup
Where nowritebackup changes the default "save" behavior of Vim, which is:
- write buffer to new file
- delete the original file
- rename the new file
and makes Vim write the buffer to the original file (resulting in the risk of destroying it in case of an I/O error). But you prevent "jumping files" on the Windows desktop with it, which is the primary reason for me to have nowritebackup in place.
7
+1 Foryou prevent "jumping files" on the Windows desktop. Googled and found this answer
– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
1
Actually - do I have to have bothnobackupandnowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?
– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
@Merlyn: If you havebackup(as opposed tonobackup), then Vim will create a backup (the*.ext~file). This is completely unrelated tonowritebackup.
– Tomalak
Mar 28 '11 at 22:26
5
There is a table describing different behavior between combination of those switches:help backup-table. It turns out setting neithernobackupnornowritebackup, but instead settingbackupcopy=yesalso solves the "jumping" problem. This may hurt perf, though, so to each their own
– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
24
Instead of turning off , backup to a directoryset backupdir=~/.vim/backupin .vimrc or _vimrc on windows
– tsukimi
Dec 5 '13 at 1:10
|
show 1 more comment
up vote
205
down vote
accepted
The *.ext~ file is a backup file, containing the file as it was before you edited it.
The *.ext.swp file is the swap file, which serves as a lock file and contains the undo/redo history as well as any other internal info Vim needs. In case of a crash you can re-open your file and Vim will restore its previous state from the swap file (which I find helpful, so I don't switch it off).
To switch off automatic creation of backup files, use (in your vimrc):
set nobackup
set nowritebackup
Where nowritebackup changes the default "save" behavior of Vim, which is:
- write buffer to new file
- delete the original file
- rename the new file
and makes Vim write the buffer to the original file (resulting in the risk of destroying it in case of an I/O error). But you prevent "jumping files" on the Windows desktop with it, which is the primary reason for me to have nowritebackup in place.
7
+1 Foryou prevent "jumping files" on the Windows desktop. Googled and found this answer
– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
1
Actually - do I have to have bothnobackupandnowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?
– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
@Merlyn: If you havebackup(as opposed tonobackup), then Vim will create a backup (the*.ext~file). This is completely unrelated tonowritebackup.
– Tomalak
Mar 28 '11 at 22:26
5
There is a table describing different behavior between combination of those switches:help backup-table. It turns out setting neithernobackupnornowritebackup, but instead settingbackupcopy=yesalso solves the "jumping" problem. This may hurt perf, though, so to each their own
– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
24
Instead of turning off , backup to a directoryset backupdir=~/.vim/backupin .vimrc or _vimrc on windows
– tsukimi
Dec 5 '13 at 1:10
|
show 1 more comment
up vote
205
down vote
accepted
up vote
205
down vote
accepted
The *.ext~ file is a backup file, containing the file as it was before you edited it.
The *.ext.swp file is the swap file, which serves as a lock file and contains the undo/redo history as well as any other internal info Vim needs. In case of a crash you can re-open your file and Vim will restore its previous state from the swap file (which I find helpful, so I don't switch it off).
To switch off automatic creation of backup files, use (in your vimrc):
set nobackup
set nowritebackup
Where nowritebackup changes the default "save" behavior of Vim, which is:
- write buffer to new file
- delete the original file
- rename the new file
and makes Vim write the buffer to the original file (resulting in the risk of destroying it in case of an I/O error). But you prevent "jumping files" on the Windows desktop with it, which is the primary reason for me to have nowritebackup in place.
The *.ext~ file is a backup file, containing the file as it was before you edited it.
The *.ext.swp file is the swap file, which serves as a lock file and contains the undo/redo history as well as any other internal info Vim needs. In case of a crash you can re-open your file and Vim will restore its previous state from the swap file (which I find helpful, so I don't switch it off).
To switch off automatic creation of backup files, use (in your vimrc):
set nobackup
set nowritebackup
Where nowritebackup changes the default "save" behavior of Vim, which is:
- write buffer to new file
- delete the original file
- rename the new file
and makes Vim write the buffer to the original file (resulting in the risk of destroying it in case of an I/O error). But you prevent "jumping files" on the Windows desktop with it, which is the primary reason for me to have nowritebackup in place.
edited Mar 28 '11 at 22:24
answered Mar 3 '09 at 18:04
Tomalak
254k51422538
254k51422538
7
+1 Foryou prevent "jumping files" on the Windows desktop. Googled and found this answer
– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
1
Actually - do I have to have bothnobackupandnowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?
– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
@Merlyn: If you havebackup(as opposed tonobackup), then Vim will create a backup (the*.ext~file). This is completely unrelated tonowritebackup.
– Tomalak
Mar 28 '11 at 22:26
5
There is a table describing different behavior between combination of those switches:help backup-table. It turns out setting neithernobackupnornowritebackup, but instead settingbackupcopy=yesalso solves the "jumping" problem. This may hurt perf, though, so to each their own
– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
24
Instead of turning off , backup to a directoryset backupdir=~/.vim/backupin .vimrc or _vimrc on windows
– tsukimi
Dec 5 '13 at 1:10
|
show 1 more comment
7
+1 Foryou prevent "jumping files" on the Windows desktop. Googled and found this answer
– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
1
Actually - do I have to have bothnobackupandnowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?
– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
@Merlyn: If you havebackup(as opposed tonobackup), then Vim will create a backup (the*.ext~file). This is completely unrelated tonowritebackup.
– Tomalak
Mar 28 '11 at 22:26
5
There is a table describing different behavior between combination of those switches:help backup-table. It turns out setting neithernobackupnornowritebackup, but instead settingbackupcopy=yesalso solves the "jumping" problem. This may hurt perf, though, so to each their own
– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
24
Instead of turning off , backup to a directoryset backupdir=~/.vim/backupin .vimrc or _vimrc on windows
– tsukimi
Dec 5 '13 at 1:10
7
7
+1 For
you prevent "jumping files" on the Windows desktop. Googled and found this answer– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
+1 For
you prevent "jumping files" on the Windows desktop. Googled and found this answer– Merlyn Morgan-Graham
Mar 28 '11 at 22:16
1
1
Actually - do I have to have both
nobackup and nowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
Actually - do I have to have both
nobackup and nowritebackup? Is there a way to write a copy of the file as a backup, but not do this write/delete/rename stuff?– Merlyn Morgan-Graham
Mar 28 '11 at 22:22
@Merlyn: If you have
backup (as opposed to nobackup), then Vim will create a backup (the *.ext~ file). This is completely unrelated to nowritebackup.– Tomalak
Mar 28 '11 at 22:26
@Merlyn: If you have
backup (as opposed to nobackup), then Vim will create a backup (the *.ext~ file). This is completely unrelated to nowritebackup.– Tomalak
Mar 28 '11 at 22:26
5
5
There is a table describing different behavior between combination of those switches:
help backup-table. It turns out setting neither nobackup nor nowritebackup, but instead setting backupcopy=yes also solves the "jumping" problem. This may hurt perf, though, so to each their own– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
There is a table describing different behavior between combination of those switches:
help backup-table. It turns out setting neither nobackup nor nowritebackup, but instead setting backupcopy=yes also solves the "jumping" problem. This may hurt perf, though, so to each their own– Merlyn Morgan-Graham
Mar 28 '11 at 22:34
24
24
Instead of turning off , backup to a directory
set backupdir=~/.vim/backup in .vimrc or _vimrc on windows– tsukimi
Dec 5 '13 at 1:10
Instead of turning off , backup to a directory
set backupdir=~/.vim/backup in .vimrc or _vimrc on windows– tsukimi
Dec 5 '13 at 1:10
|
show 1 more comment
up vote
199
down vote
I think the better solution is to place these lines in your vimrc file
set backupdir=~/vimtmp,.
set directory=~/vimtmp,.
You have to create a directory in your home directory called vimtmp for this to work.
That way you get the benefit of both worlds, you don't have to see the files, but if something does get futzed you can go get your backup file from vimtmp. Don't forget to clean the directory out every now and then.
19
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
10
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
7
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
2
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
11
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
|
show 8 more comments
up vote
199
down vote
I think the better solution is to place these lines in your vimrc file
set backupdir=~/vimtmp,.
set directory=~/vimtmp,.
You have to create a directory in your home directory called vimtmp for this to work.
That way you get the benefit of both worlds, you don't have to see the files, but if something does get futzed you can go get your backup file from vimtmp. Don't forget to clean the directory out every now and then.
19
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
10
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
7
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
2
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
11
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
|
show 8 more comments
up vote
199
down vote
up vote
199
down vote
I think the better solution is to place these lines in your vimrc file
set backupdir=~/vimtmp,.
set directory=~/vimtmp,.
You have to create a directory in your home directory called vimtmp for this to work.
That way you get the benefit of both worlds, you don't have to see the files, but if something does get futzed you can go get your backup file from vimtmp. Don't forget to clean the directory out every now and then.
I think the better solution is to place these lines in your vimrc file
set backupdir=~/vimtmp,.
set directory=~/vimtmp,.
You have to create a directory in your home directory called vimtmp for this to work.
That way you get the benefit of both worlds, you don't have to see the files, but if something does get futzed you can go get your backup file from vimtmp. Don't forget to clean the directory out every now and then.
answered Oct 26 '09 at 16:44
user183135
2,2302147
2,2302147
19
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
10
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
7
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
2
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
11
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
|
show 8 more comments
19
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
10
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
7
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
2
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
11
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
19
19
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
+1 I actually have mine set to ~/.vim/tmp, but either way, this has saved my ass on more than one occasion.
– jonyamo
Jun 6 '11 at 19:01
10
10
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
Why do you need ,. at the end of each line?
– shin
Jan 30 '14 at 1:07
7
7
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
@shin Vim will use the first available dir, so in this case if ~/vimtmp doesn't exist it will use the current working directory
– xixixao
Jan 30 '14 at 21:58
2
2
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
@SalmanPK In an ideal world you should not be editing configuration files directly on publicly accessible servers
– Score_Under
Aug 20 '14 at 2:31
11
11
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
Use two slashes at the end of the path. For instance, set backupdir=~/.vim/.backup// - the "//" at the end of the directory means that file names will be built from the complete path to the file with all path separators substituted to percent "%" sign. This will ensure file name uniqueness in the preserve directory.
– Hacknightly
Jun 12 '16 at 17:58
|
show 8 more comments
up vote
23
down vote
To turn off those files, just add these lines to .vimrc (vim configuration file on unix based OS):
set nobackup #no backup files
set nowritebackup #only in case you don't want a backup file while editing
set noswapfile #no swap files
add a comment |
up vote
23
down vote
To turn off those files, just add these lines to .vimrc (vim configuration file on unix based OS):
set nobackup #no backup files
set nowritebackup #only in case you don't want a backup file while editing
set noswapfile #no swap files
add a comment |
up vote
23
down vote
up vote
23
down vote
To turn off those files, just add these lines to .vimrc (vim configuration file on unix based OS):
set nobackup #no backup files
set nowritebackup #only in case you don't want a backup file while editing
set noswapfile #no swap files
To turn off those files, just add these lines to .vimrc (vim configuration file on unix based OS):
set nobackup #no backup files
set nowritebackup #only in case you don't want a backup file while editing
set noswapfile #no swap files
edited Mar 3 '09 at 18:14
answered Mar 3 '09 at 18:04
rogeriopvl
27k74557
27k74557
add a comment |
add a comment |
up vote
12
down vote
:set nobackup
will turn off backups. You can also set a backupdir if you still want those backup files but in a central folder. This way your working dir is not littered with ~ files.
You find more information on backups under :he backup.
add a comment |
up vote
12
down vote
:set nobackup
will turn off backups. You can also set a backupdir if you still want those backup files but in a central folder. This way your working dir is not littered with ~ files.
You find more information on backups under :he backup.
add a comment |
up vote
12
down vote
up vote
12
down vote
:set nobackup
will turn off backups. You can also set a backupdir if you still want those backup files but in a central folder. This way your working dir is not littered with ~ files.
You find more information on backups under :he backup.
:set nobackup
will turn off backups. You can also set a backupdir if you still want those backup files but in a central folder. This way your working dir is not littered with ~ files.
You find more information on backups under :he backup.
answered Mar 3 '09 at 18:02
f3lix
23.6k95578
23.6k95578
add a comment |
add a comment |
up vote
11
down vote
And you can also set a different backup extension and where to save those backup (I prefer ~/.vimbackups on linux). I used to use "versioned" backups, via:
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'
This sets a dynamic backup extension (ORIGINALFILENAME-YYYYMMDD-HHMMSS.vimbackup).
3
you might want to include how to set up the back up directory, i.e. puttingset backupdir=~/.vimbackupsin your ~/.vimrc
– rampion
Mar 3 '09 at 22:30
1
The vim help fully describes this technique. See:help backupext
– netjeff
Jun 9 '11 at 19:05
add a comment |
up vote
11
down vote
And you can also set a different backup extension and where to save those backup (I prefer ~/.vimbackups on linux). I used to use "versioned" backups, via:
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'
This sets a dynamic backup extension (ORIGINALFILENAME-YYYYMMDD-HHMMSS.vimbackup).
3
you might want to include how to set up the back up directory, i.e. puttingset backupdir=~/.vimbackupsin your ~/.vimrc
– rampion
Mar 3 '09 at 22:30
1
The vim help fully describes this technique. See:help backupext
– netjeff
Jun 9 '11 at 19:05
add a comment |
up vote
11
down vote
up vote
11
down vote
And you can also set a different backup extension and where to save those backup (I prefer ~/.vimbackups on linux). I used to use "versioned" backups, via:
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'
This sets a dynamic backup extension (ORIGINALFILENAME-YYYYMMDD-HHMMSS.vimbackup).
And you can also set a different backup extension and where to save those backup (I prefer ~/.vimbackups on linux). I used to use "versioned" backups, via:
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'
This sets a dynamic backup extension (ORIGINALFILENAME-YYYYMMDD-HHMMSS.vimbackup).
edited Feb 6 '12 at 7:11
answered Mar 3 '09 at 22:13
Zsolt Botykai
37.9k107196
37.9k107196
3
you might want to include how to set up the back up directory, i.e. puttingset backupdir=~/.vimbackupsin your ~/.vimrc
– rampion
Mar 3 '09 at 22:30
1
The vim help fully describes this technique. See:help backupext
– netjeff
Jun 9 '11 at 19:05
add a comment |
3
you might want to include how to set up the back up directory, i.e. puttingset backupdir=~/.vimbackupsin your ~/.vimrc
– rampion
Mar 3 '09 at 22:30
1
The vim help fully describes this technique. See:help backupext
– netjeff
Jun 9 '11 at 19:05
3
3
you might want to include how to set up the back up directory, i.e. putting
set backupdir=~/.vimbackups in your ~/.vimrc– rampion
Mar 3 '09 at 22:30
you might want to include how to set up the back up directory, i.e. putting
set backupdir=~/.vimbackups in your ~/.vimrc– rampion
Mar 3 '09 at 22:30
1
1
The vim help fully describes this technique. See
:help backupext– netjeff
Jun 9 '11 at 19:05
The vim help fully describes this technique. See
:help backupext– netjeff
Jun 9 '11 at 19:05
add a comment |
up vote
6
down vote
You're correct that the .swp file is used by vim for locking and as a recovery file.
Try putting set nobackup in your vimrc if you don't want these files. See the Vim docs for various backup related options if you want the whole scoop, or want to have .bak files instead...
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
add a comment |
up vote
6
down vote
You're correct that the .swp file is used by vim for locking and as a recovery file.
Try putting set nobackup in your vimrc if you don't want these files. See the Vim docs for various backup related options if you want the whole scoop, or want to have .bak files instead...
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
add a comment |
up vote
6
down vote
up vote
6
down vote
You're correct that the .swp file is used by vim for locking and as a recovery file.
Try putting set nobackup in your vimrc if you don't want these files. See the Vim docs for various backup related options if you want the whole scoop, or want to have .bak files instead...
You're correct that the .swp file is used by vim for locking and as a recovery file.
Try putting set nobackup in your vimrc if you don't want these files. See the Vim docs for various backup related options if you want the whole scoop, or want to have .bak files instead...
answered Mar 3 '09 at 18:03
dwc
18.3k53651
18.3k53651
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
add a comment |
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
+1 for mentioning the purpose as a lock file. I didn't think of that.
– Tomalak
Mar 3 '09 at 18:36
add a comment |
up vote
5
down vote
Put this line into your vimrc:
set nobk nowb noswf noudf " nobackup nowritebackup noswapfile noundofile
In Windows that would be the C:Program Files (x86)vim_vimrc file for system-wide vim configuration for all users.
Setting the last one noundofile is important in Windows to prevent the creation of *~ tilda files after editing.
I wish Vim had that line included by default. Nobody likes ugly directories.
Let the user choose if and how she wants to enable advanced backup/undo file features first.
This is the most annoying part of Vim.
The next step is to set up set noeb vb t_vb= to disable beeping :P
add a comment |
up vote
5
down vote
Put this line into your vimrc:
set nobk nowb noswf noudf " nobackup nowritebackup noswapfile noundofile
In Windows that would be the C:Program Files (x86)vim_vimrc file for system-wide vim configuration for all users.
Setting the last one noundofile is important in Windows to prevent the creation of *~ tilda files after editing.
I wish Vim had that line included by default. Nobody likes ugly directories.
Let the user choose if and how she wants to enable advanced backup/undo file features first.
This is the most annoying part of Vim.
The next step is to set up set noeb vb t_vb= to disable beeping :P
add a comment |
up vote
5
down vote
up vote
5
down vote
Put this line into your vimrc:
set nobk nowb noswf noudf " nobackup nowritebackup noswapfile noundofile
In Windows that would be the C:Program Files (x86)vim_vimrc file for system-wide vim configuration for all users.
Setting the last one noundofile is important in Windows to prevent the creation of *~ tilda files after editing.
I wish Vim had that line included by default. Nobody likes ugly directories.
Let the user choose if and how she wants to enable advanced backup/undo file features first.
This is the most annoying part of Vim.
The next step is to set up set noeb vb t_vb= to disable beeping :P
Put this line into your vimrc:
set nobk nowb noswf noudf " nobackup nowritebackup noswapfile noundofile
In Windows that would be the C:Program Files (x86)vim_vimrc file for system-wide vim configuration for all users.
Setting the last one noundofile is important in Windows to prevent the creation of *~ tilda files after editing.
I wish Vim had that line included by default. Nobody likes ugly directories.
Let the user choose if and how she wants to enable advanced backup/undo file features first.
This is the most annoying part of Vim.
The next step is to set up set noeb vb t_vb= to disable beeping :P
answered Jul 10 '17 at 2:34
w17t
6821017
6821017
add a comment |
add a comment |
up vote
4
down vote
The only option that worked for me was to put this line in my ~/.vimrc file
set noundofile
The other options referring to backup files did not prevent the creation of the temp files ending in ~ (tilde)
add a comment |
up vote
4
down vote
The only option that worked for me was to put this line in my ~/.vimrc file
set noundofile
The other options referring to backup files did not prevent the creation of the temp files ending in ~ (tilde)
add a comment |
up vote
4
down vote
up vote
4
down vote
The only option that worked for me was to put this line in my ~/.vimrc file
set noundofile
The other options referring to backup files did not prevent the creation of the temp files ending in ~ (tilde)
The only option that worked for me was to put this line in my ~/.vimrc file
set noundofile
The other options referring to backup files did not prevent the creation of the temp files ending in ~ (tilde)
answered Apr 6 '17 at 15:18
Logan
412
412
add a comment |
add a comment |
up vote
0
down vote
I had to add set noundofile to ~_gvimrc
The "~" directory can be identified by changing the directory with the cd ~ command
add a comment |
up vote
0
down vote
I had to add set noundofile to ~_gvimrc
The "~" directory can be identified by changing the directory with the cd ~ command
add a comment |
up vote
0
down vote
up vote
0
down vote
I had to add set noundofile to ~_gvimrc
The "~" directory can be identified by changing the directory with the cd ~ command
I had to add set noundofile to ~_gvimrc
The "~" directory can be identified by changing the directory with the cd ~ command
answered Mar 1 at 19:44
Josh
90811014
90811014
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f607435%2fwhy-does-vim-save-files-with-a-extension%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you have any file open simultaneously in more than one place, they will create a
.ext.swp.– dirkgently
Mar 3 '09 at 18:00
1
dirkgently: No, on here I can open a file in the only vim window and it will create the .swp file. I'm not too fussed about that as it's removed when I save/close the window.
– Ross
Mar 3 '09 at 18:02