Skip to main content
26 votes

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

Here is the vim commands you need to view the diff, resolve any differences, and save the file. All done without quitting vim or using plugins. From the command line, open the file, there will be a ...
Trevor Boyd Smith's user avatar
12 votes
Accepted

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

Edit the same file again. Vim will prompt you with a few options; say you want to Recover. Then save the file, quit Vim, and remove the swap file (otherwise Vim will prompt you again the next time ...
Sato Katsura's user avatar
  • 4,019
10 votes

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

View diff of a swap file without plugins Without plugins, you can use vim alternate-file. Wikia source: Diff current buffer and the original file In short, try this: :diffthis | :vnew | r # | exe &...
Yasen's user avatar
  • 501
10 votes

Is it possible to make Vim auto-save files?

I made a plugin vim-autosave which uses Vim 8 feature of Timers to periodically save your buffers.
Christian Brabandt's user avatar
9 votes

How to show all unsaved files opened in vim?

:ls shows the current buffers (opened files) A + mark before file path shows that file is modified. Check :h :ls for more details
NikitQa's user avatar
  • 161
3 votes

Automatically delete swap file if it matches the saved file

Since you do not need the swap-functionality, you can disable it using :set noswapfile or include set noswapfile in your .vimrc.
Ashok Arora's user avatar
3 votes

Is it possible to make Vim auto-save files?

I make my Vim save everything every time focus is lost. autocmd FocusLost <your-patterns-here> silent! wall My patterns are pretty long and I use them in several autocmds but for completeness ...
dash-tom-bang's user avatar
2 votes

Is it possible to make Vim auto-save files?

Try to saves the buffer whenever text is changed: autocmd TextChanged,TextChangedI <buffer> silent write This works for me. Source
simhumileco's user avatar
2 votes

Is it possible to make Vim auto-save files?

The vim-workspace plugin has a fairly customizable auto-save feature that may suit your needs. By default, it enables autosave when in a workspace session (its main feature), but you can set it to ...
jaybay's user avatar
  • 91
2 votes

What is the purpose of swap files?

One great way to avoid creating annoying swap files is to open files you don't intend to change with the -R flag. This makes the file read-only and has a nice side effect of not creating a swap file. ...
rkuris's user avatar
  • 121
2 votes

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

Based off Trevor's answer, I made the following commands for dealing with swap files: noremap <LEADER>s <C-w>o:sav! ~/.vim/.recovered<CR>:vs<CR><C-w>w:bn<CR> ...
Simon Alford's user avatar
1 vote

I don't understand the logic of recovering crashed edit files

See :help usr_11.txt for documentation about recovery. (There's something about warning when the file being newer than the swapfile in section 11.3 “Crashed or not?”)
1 vote

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

This answer has my upvote but I think in many cases it is wrong for my workflow, especially for what is likely to be small changes which is usually the case for me. Instead, I suggest using: The (R)...
Aaron Hall's user avatar
1 vote

How to show all unsaved files opened in vim?

Adding to what muru posted, here's a 'not easy' way to control the processes hanging out there: create and chmod +x type.py: #!/usr/bin/python import argparse import fcntl,termios p = argparse....
M Virts's user avatar
  • 111
1 vote

Is it possible to make Vim auto-save files?

Put this on your vimrc: """""""""""""""""""""""""""""&...
Adrian Lopez's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible