Socket
Book a DemoInstallSign in
Socket

vim-recovery

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vim-recovery

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

vim-recovery

vim-recovery is a utility to find and recover swapfiles.

Rationale

After a system crash, my system is often littered with Vim swapfiles. I usually want to do two things. (1) Recover my in-progress work (unsaved files) and (2) remove any unmodified files to prevent Vim from prompting me about the swapfile whenever I open a file.

find . -type f -name "*.sw[a-p]" doesn't take into account the actual type of the file. For example, it finds Shockwave Flash files (*.swf).

vim-recovery searches directories for swap files and checks the header of the file to determine if it actually is a Vim swapfile.

Installation

$ gem install vim-recovery

Usage

$ vim-recovery --help
Usage:  vim-recovery [options] [paths...]
Commands:
    -l, --list                       Find and list Vim swapfiles
        --clean                      Delete unmodified swapfiles if process is not still running
Options:
    -r, --recursive                  Also search subdirectories
    -v, --verbose                    Be more verbose

        --version                    Show version
    -h, --help                       Display this help

Finding swapfiles

The "M" flag means the file was modified, and the "R" flag means the process is still running. The output is tab-delimited to make it easier to parse with tools such as cut.

$ vim-recovery --list
[ R]	./.gitignore.swp	~speckins/git/vim-recovery/.gitignore
[MR]	./.README.md.swp	~speckins/git/vim-recovery/README.md
[ R]	./.vim-recovery.gemspec.swp	~speckins/git/vim-recovery/vim-recovery.gemspec
[  ]	./.crashed.txt.swp	~speckins/git/vim-recovery/crashed.txt

Removing unmodified swapfiles

$ vim-recovery --clean --verbose
./.crashed.txt.swp

$ vim-recovery --list
[ R]	./.gitignore.swp	~speckins/git/vim-recovery/.gitignore
[MR]	./.README.md.swp	~speckins/git/vim-recovery/README.md
[ R]	./.vim-recovery.gemspec.swp	~speckins/git/vim-recovery/vim-recovery.gemspec

Recursively cleaning swapfiles

$ vim-recovery --clean --recursive --verbose
./.crashed.txt.swp
./lib/vim_recovery/.crashed.txt.swp

Filtering the output of --list

$ vim-recovery --list --recursive
[ R]	./.gitignore.swp	~speckins/git/vim-recovery/.gitignore
[MR]	./.README.md.swp	~speckins/git/vim-recovery/README.md
[ R]	./.vim-recovery.gemspec.swp	~speckins/git/vim-recovery/vim-recovery.gemspec
[M ]	./.crashed.txt.swp	~speckins/git/vim-recovery/crashed.txt

$ vim-recovery --list --recursive | grep -a '^\[M \]' | cut -f2
./.crashed.txt.swp

Vim options

The directory option can be added to .vimrc to make it easier to find swapfiles. This is not necessary to use vim-recovery, but it can make it faster. (It takes a long time to search the 900,000+ files in my home directory.)

" .vimrc:
set directory=~/tmp/swapfiles//

For Unix and Win32, if a directory ends in two path separators "//" or "\\", the swap file name will be built from the complete path to the file with all path separators substituted to percent '%' signs. This will ensure file name uniqueness in the preserve directory.

FAQs

Package last updated on 06 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.