Skip to content

Please Vim, stop with these swap file messages. Just switch to the correct window!

License

Notifications You must be signed in to change notification settings

gioele/vim-autoswap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 

Repository files navigation

vim-autoswap

Please Vim, stop with these swap file messages. Just switch to the correct window!

Why autoswap?

Dealing with swap files is annoying. Most of the time you have to deal with a swap file because you either have the same file open in another window or it is a swap file left there by a previous crash.

This plugin does for you what you would do in these cases:

  1. Is file already open in another Vim session in some other window?
  2. If so, swap to the window where we are editing that file.
  3. Otherwise, if swapfile is older than file itself, just get rid of it.
  4. Otherwise, open file read-only so we can have a look at it and may save it.

Damian Conway presented this plugin at OSCON 2013 in his talk "More instantly better Vim".

The original version of this plugin (only for MacOS) is available at http://is.gd/IBV2013, together with other plugins presented in the same talk. This version has been modified to work also on Linux systems. Both Vim and GVim are supported.

Limitations

At the moment this plugin does not reliably detect files open within tabs in Apple Terminal and iTerm2 as it matches based on the window name, not tab name.

Installation

Copy the autoswap.vim file in your ~/.vim/plugin directory.

Or use pathogen and just clone the git repository:

$ cd ~/.vim/bundle
$ git clone https://github.com/gioele/vim-autoswap.git

Make sure that the title option is enabled and the titlestring variable contains the filename and the string VIM (the default titlestring will work just fine). To enable the title option set it in your ~/.vimrc file:

$ echo 'set title titlestring=' >> ~/.vimrc

Linux users: you must install wmctrl to be able to automatically switch to the Vim window with the open file. wmctrl is already packaged for most distributions.

KDE/Konsole users: in addition to wmctrl you must install also the vim-konsole plugin.

tmux users: if tmux is detected, autoswap can change the current pane to the one where vim is already open. tmux support is disabled by default. To enable support for tmux add let g:autoswap_detect_tmux = 1 to your .vimrc.

If you use Arch Linux you can install via the vim-autoswap-git package in the AUR. The package will install this plugin and all the needed dependencies.

Authors

Development

Code : http://svario.it/vim-autoswap (redirects to GitHub)

Report issues : http://svario.it/vim-autoswap/issues

License

This is free software released into the public domain (CC0 license).

See the COPYING.CC0 file or http://creativecommons.org/publicdomain/zero/1.0/ for more details.

About

Please Vim, stop with these swap file messages. Just switch to the correct window!

Resources

License

Stars

Watchers

Forks

Packages

No packages published