Questions tagged [swap-file]

Vim stores changes made to a buffer on disk to a swap file, so that any unsaved changes can be recovered in case of a crash.

Filter by
Sorted by
Tagged with
1 vote
1 answer
13 views

Extract list of outstanding changes from Vim swap file

I end up with swap files from crashed Vim sessions (typically ssh session timeouts) often enough, and I'm wondering if there is a way to determine exactly what changes are describe by the swap file. (...
2 votes
2 answers
60 views

Stop vim from deleting Swap file

I like Vim's swap file system and I want to be prepared for the case I forget to :w, reusing this system. I think it's possible if I can change when Vim deletes the swap file, but I could not find the ...
0 votes
1 answer
59 views

"Unable to open swap file for 'Makefile', recovery impossible" for every edited file in vim

Upon editing any file I am now seeing this: In order to isolate this I have deleted all of the contents of ~/.vim or ~/.vimrc. I then consulted note here and recreated the `~/.vimrc with these ...
2 votes
1 answer
43 views

Is it possible to keep a swap file but disable the auto-recovery mechanism?

I want to have swap files for manual inspection if needed, i.e. I don't want ViM to ask me every time I have a swap file if I want to recover / edit, etc. but I do want to have the option to manually ...
0 votes
0 answers
29 views

netrw: NetrwMessage.swp blocks simultaneous edit of multiple remote files

Launching Vim with a remote file... vim scp://foo.example.com//etc/foo.conf seems to create a swapfile... ~/.local/share/nvim/swap//%usr%home%georg%NetrwMessage.swp Launching another instance of Vim,...
  • 1
0 votes
0 answers
33 views

How to disable "E768 swap file exists warning"

I get this annoying message when I write file (using write). How can I disable it? E768: Swap file exists: c:\users\ekarni\.vim\swap\template.py.swp (:silent! overrides) Since I did silent! ...
  • 1,164
2 votes
0 answers
105 views

How do I recover a specific swap file?

Last night I wrote a short piece the saved saved and exited (:wq). Then the goat-rope of trying to recover what apparently seemed to vanish stated. Since it was about 3 AM and I was getting no where, ...
  • 121
0 votes
1 answer
53 views

Neovim autoupdating file in multiple terminal buffers, not warning with swap

I've been noticing some rather confusing behavior in my neovim setup and I'm really not even sure if it's a problem, just a feature that surprised me. I recently noticed that the classic "This ...
  • 475
1 vote
1 answer
78 views

How can I stop vim from moving / deleting a file just before saving?

When I save a file in vim, it does following operations: $ inotifywait -r -m -c src/ src/,CREATE,4913 src/,OPEN,4913 src/,ATTRIB,4913 src/,"CLOSE_WRITE,CLOSE",4913 src/,DELETE,4913 src/,...
0 votes
0 answers
34 views

Check if any vi process is editing a file, or swapfile exists?

I'm writing a script to ensure that everything I work on on my system is committed, pushed to Git etc. I'd also like to check if there are any vim swapfiles active (either in a running Vim, or from ...
  • 335
0 votes
1 answer
118 views

Why are empty files with names as 4 digits being generated by VIM?

I've been using VIM on a virtual machine running Kali Linux to write python scripts on a shared folder on my Windows 10 host operating system, but these empty files with names as 4 digits keep being ...
  • 1
0 votes
0 answers
18 views

saving a .v file triggers it to be opened in another window and gets E:325 in neovim

After trying to save a .v file, it triggers a new window to be opened with e:325 error with swap file already exists. This only happens to .v files. This only happens when neovim is opened from that ...
0 votes
1 answer
431 views

How to recover unsaved text without a swap file after Vim crashed?

I am using Vim 8 in WSL Ubuntu. While copying text into a file the terminal crashed. I don't believe it is the WSL as Task Manager does not show 'Not Responding'. I have tried using this answer which ...
  • 135
1 vote
1 answer
89 views

simultaneous "vi <(command)" in macOS

In macOS Catalina, from Terminal, bash, vim 8.1, I launch vi <(command1) to see the output of a command. From another terminal, I launch another vi <(command2). Then vim complains that it's ...
6 votes
1 answer
163 views

How can I view the name of the swapfile being used for the current buffer?

Let's say I recovered a bunch of swapfiles in quick succession: gvim -r .swv gvim -r .swu gvim -r .swt And then cycled through them all a few times before finding that one of them was nonsense. I ...
  • 163
10 votes
1 answer
819 views

vim: (E)dit anyway without prompting

I work with many terminals, and very often hit the case where: a vim instance holds ~/sm/file I open another instance on the same file. My choice is always :(E)dit without prompting ... So I'd like ...
  • 201
0 votes
0 answers
122 views

Disable E303 warning when swap directory isn't writeable

I sometimes run vim as another user than me, using my own vimrc. In this case the swp and undo directory aren't writeable, and vim warns me with E303. I don't care about not having swap file in this ...
  • 111
2 votes
1 answer
1k views

Auto-Deleting Swaps, Backups and Undos while Quitting vim?

Cluttering Swaps and Backups that I never use are so annoying and takes up unnecessary space. Is there a way to delete them as one quits vim with :q and similar quitting commands?
  • 221
0 votes
0 answers
191 views

make vim produce patch files without editing originals

I want to edit text files with vim, I would love vim file.txt To work like normal, and open file.txt in vim, like normal, and allow me to edit it seemingly like normal. The only difference is, all ...
  • 1,737
1 vote
1 answer
137 views

Why is my small SQL comment not backed up in the .swp file?

Problem: The changes I make in files before closing are not saved in .swp files As I understand it, the swap file should save any changes if they are at least 200 characters long or nothing has been ...
1 vote
2 answers
675 views

Why are swap files so big?

I open a file with vim, vim creates a swap file. Though I have not done any single edit on my file, the swap file has significant size, sometimes bigger than the size of the original file. For ...
  • 13
0 votes
2 answers
177 views

Minimal swap file use or deleting only swapfiles without changes

When I lose power, I have a lot of maybe-useful swap files (4 vim instances running now, 103 swap files currently in ~/.cache/vim/swap). I am fine with manual recovery of swapfiles with changes - I'd ...
  • 183
2 votes
0 answers
242 views

Vim Swap File Became 187 GB, What are Possible Explanations?

I am running an Ubuntu Subsystem for Windows 10. Within Ubuntu, I worked on a small file via vim and backgrounded it (CTRL-Z) and foregrounded it (% job #) multiple times over a couple day period. Out ...
0 votes
1 answer
1k views

Swapfile issues with vim when using remote Windows 10 SMB Share?

I'm using vim on a Linux machine to write to a Windows 10 share and vim keeps slowing down and giving an error at the status line of E297: Write error in swap file. When I went into the directory to ...
  • 3,153
3 votes
0 answers
2k views

How to recover from swap files correctly on Neovim?

My Mac crashed and was forced to restart. So I opened Terminal, try recovering the file, but struggle to correctly recover the file. Specifically, I tried the following command: nvim ~/.config/nvim/...
  • 487
26 votes
2 answers
10k views

VIM swap-file best practices?

Everytime I cut out of a session in vim by losing my connection I'm rather filled with dred (and yet I continue to use vim...what a masochistist I must be) because when I open my files again a pile ...
  • 3,153
0 votes
1 answer
45 views

Discover which other user(s) are accessing a file

Every time I vim open, I get the standard warning about another user, swap file already exists, abort/quit/.., etc. I've been trying for at least 2 hours, and I'm sure I don't have the file open ...
  • 117
19 votes
4 answers
9k views

How do you view the diff of a swap file without quitting `vim`?

I have a way to handle swap files. And it works but it takes a while. Here goes: First I try to find the original vim session -- track down if the PID is still alive -- and if the PID is still ...
4 votes
0 answers
6k views

How to delete swap files on neovim?

While editing a file my neovim crashed when I tried to save the file (with the error message "init.vim" 77L, 2423C writtennvim(5888,0x7fffa9f29340) malloc: *** error for object ...
  • 487
6 votes
1 answer
2k views

Automatically delete swap file if it matches the saved file

As a developer who grew up on hardware with no MMU I have a habit of saving my work often, usually after every insert. Thus, when presented with the recovery dialogue after a crash or disconnect there ...
  • 221
5 votes
0 answers
2k views

Vim error: Unable to open swap file when using backslash as path separator in Windows shell

I'm using cmder as my Win7 shell. I see the following behaviour: Works fine (file in current directory): vim test Works fine (absolute path): vim ~/test Works fine (relative path with forward ...
2 votes
2 answers
103 views

Can I have a per-directory setting for where swap files are stored?

I’m usually fine with swap files being created in the same directory as the files being edited—I have the directory setting left on its default value. I have one project, though, with “file watching” ...
  • 2,573
8 votes
3 answers
9k views

How to resolve E303 (Unable to open swap file) on Linux machine?

I get E303 (Unable to open swap file for "{filename}", recovery impossible) when I open a file in vim in my Ubuntu system. I see that the backupdir and directory environment variables are set ...
  • 213
3 votes
2 answers
5k views

Force prompt for whether to delete a swap file

How do you configure vim to prompt for deletion of swap files even if it believes another instance of vim may still be using the file? I still want to see the warning message ... just also have the ...
  • 1,653
3 votes
2 answers
4k views

What does shortmess+=A do about the swp file?

:h shortmess says: A don't give the "ATTENTION" message when an existing swap file is found. But then what does Vim do about the existing swap file? Some people say it's bad to use that option, ...
  • 837
0 votes
0 answers
657 views

Unable to recover .swp file

My computer crashed while in the middle of editing several vim files. Upon reboot, two of the files getting edited showed a file size 0 bytes. I was able to recover one of the .swp files with the :...
  • 1,277
1 vote
2 answers
354 views

.swp swap files for directories while browsing with netrw

Sometimes I browse around the directory of the current buffer by using :Ex. On one of my development machines, this results in a .swp file being created in every directory I visit. I've checked the ...
  • 113
9 votes
1 answer
3k views

Can a text file be recovered only from the .*.swp file?

I was remotely editing a new file: man-01-Intro.txt but the machine went down before I wrote it to disk so only the swp version was conserved. Is there anything that I can do to recover the work ...
1 vote
1 answer
43 views

How to allow editing of a file from other sources while it's already open in vim? [duplicate]

Let's say I have a text file opened in vim. I'd like to be able to edit this file from bash, let's say with the command echo "text" >> file while the file is already opened in vim. Ideally, vim ...
1 vote
1 answer
1k views

edit file without swap file within a vim session

The only workaround I can come up with is after opening a vim session: :set updatecount=0 | e +setlocal\ noswapfile FILENAME | set updatecount& Are there any shorter vim commands or options that ...
  • 249
10 votes
5 answers
43k views

"E297: Write error in swap file" due to running in a VM

UPDATE: I've tried both the :set noswapfile swapfile solution and the :e! solution and the swapfile one is better because it retains undo history even for large files, in this case meaning over 1.5 MB....
4 votes
1 answer
169 views

Swap choices: how can I "skip" instead of "quit" or "abort"?

Swap file ".file.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: I usually see this message when I accidentally :edit the wrong file, i.e., one which I'm already ...
  • 205
2 votes
2 answers
657 views

Examine swap file

I have no idea how swap files are formatted, but I'm wondering if the information in them can be directly examined somehow. I notice that trying to do this indirectly, by creating an empty file with ...
1 vote
2 answers
1k views

Swap file directory often ignored

I have this in my .vimrc: set directory=~/.vim/tmp-backup-swapfiles This directory is read- and writable by me, sensibly enough. It is part of the local filesystem and never inaccessible. However, ...
4 votes
1 answer
1k views

How to prevent vim from creating (and leaving) temporary files over webdav?

When I'm writing over webdavfs vim temporary doesn't handle temporary files properly: ll -a ls: cannot access .htaccess.swp: No such file or directory ls: cannot access .htaccess.swx: No such file or ...
  • 153
13 votes
2 answers
3k views

How to detect whether swp files contain unsaved changes?

When editing source code using gvim (v.7.4.488), I want to commit some changes the vcs (I'm using git 2.1.4 from the command line in Ubuntu linux). git --status shows which files I changed. However,...
6 votes
1 answer
2k views

Why does `set nocompatible` result in vim saving extra, all-numeric temporary files?

I've narrowed down a bug in a program I'm working on to (surprisingly) some vim behavior! The program contains a file watcher. When I write a file with vim -u NONE and all the default settings, the ...
  • 2,557
3 votes
1 answer
523 views

specifying a recovery file in nvi

I have an nvi session that got interrupted, and I'd like to recover my edits. When I type vi -r, it tells me "no files to recover." But there is a recovery file in /var/tmp/vi.recover, and when I ...
  • 133
5 votes
1 answer
2k views

Disable swap file for large files [duplicate]

I normally like to keep swap files on, but if I am editing huge log files I usually don't want them. Since I am just viewing the files in vim, it is unnecessary to have a swap file. I could just run ...
29 votes
2 answers
5k views

What's the difference between "quit" and "abort"?

When I try to open a file from multiple vim instances, I get an error with several options: Swap file "~/.vim/tmp/file.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:...
  • 541