*recover.vim* Show differences for recovered files Author: Christian Brabandt Version: 0.19 Thu, 15 Jan 2015 21:26:55 +0100 Copyright: (c) 2009, 2010, 2011, 2012, 2013 by Christian Brabandt The VIM LICENSE applies to recoverPlugin.vim and recoverPlugin.txt (see |copyright|) except use recoverPlugin instead of "Vim". NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK. ============================================================================== 1. Contents *RecoverPlugin* 1. Contents.....................................: |recoverPlugin| 2. recover Manual...............................: |recover-manual| 3. recover Feedback.............................: |recover-feedback| 4. cvim.........................................: |cvim| 5. recover History..............................: |recover-history| ============================================================================== *RecoverPlugin-manual* 2. RecoverPlugin Manual *recover-manual* Functionality When using |recovery|, it is hard to tell what has been changed between the recovered file and the actual on disk version. The aim of this plugin is to have an easy way to see differences between the recovered files and the files stored on disk. By default, it will become only active when a swap file is detected. It will then enable you to see a diff of the recovered swapfile and the actual file. You can now use the commands |:RecoverPluginGet| to get all differences from the recovered swapfile and |:RecoverPluginFinish|to discard the swapfile changes and close the diff mode. Thus those two commands work to easily discard the changes |:RecoverPluginFinish| or to recover |:RecoverPluginGet| from the swapfile. This plugin sets up an auto command that will create a diff buffer between the recovered file and the on-disk version of the same file. You can easily see what has been changed and save your recovered work back to the file on disk. By default this plugin is enabled. To disable it, use > :RecoverPluginDisable < To enable this plugin again, use > :RecoverPluginEnable < When you open a file and vim detects that an |swap-file| already exists for a buffer, the plugin presents the default Swap-Exists dialog from Vim adding one additional option for Diffing (but leaves out the lengthy explanation about handling swapfiles that Vim by default shows): > Found a swap file by the name "test/normal/.testfile.swp" owned by: chrisbra dated: Wed Nov 28 16:26:42 2012 file name: ~chrisbra/code/git/vim/Recover/test/normal/testfile modified: YES user name: chrisbra host name: R500 process ID: 4878 [not existing] While opening file "test/normal/testfile" dated: Tue Nov 6 20:11:55 2012 Please choose: [C]ompare, (O)pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete: (Note, it also shows the process IDor [not existing] if that process doesn't exist.) Simply use the key that is highlighted to chose the option. If you press Ctrl-C, the default dialog of Vim will be shown. If you have said 'Compare', the plugin opens a new vertical splitt buffer. On the left side, you'll find the file as it is stored on disk and the right side will contain your recovered version of the file (using the found swap file). When you want to keep the version from the swap file, use the command ":FinishRecovery" to close the diff view and delete the swapfile. When you want to discard the swap file, use the command ":1,$+1diffget" in the right window, then close the diff view and delete the swapfile with |:FinishRecovery|. You can also use the command |:RecoverPluginGet|, which will automatically retrieve all changes and finish recovery. Alternatively you can use the |merge| commands to copy selected content to the buffer on the right that holds your recovered version. If you are finished, you can close the diff version and close the window, by issuing |:diffoff!| and |:close| in the window, that contains the on-disk version of the file. Be sure to save the recovered version of you file and afterwards you can safely remove the swap file. *RecoverPlugin-Neovim* Note: When using Vim and Neovim to edit files at the same time make sure, both are configured to use the same swapfile directory (set the |'dir'| option), otherwise one Vim won't notice if Neovim has opened the same file (and Neovim won't notice if Vim has opened the file) and no dialogue would be shown. This happens, because Neovim by default uses the XDG-specification to store swap files, while Vim usually stores the swapfile next to the actual edited file. *:RecoverPluginFinish* *:FinishRecovery* In the recovered buffer, the command > :FinishRecovery < deletes the swapfile closes the diff window and finishes everything up. Alternatively you can also use the command > :RecoverPluginFinish < *:RecoverPluginHelp* The command > :RecoverPluginHelp < show a small message, on what keys can be used to move to the next different region and how to merge the changes from one windo into the other. *:RecoverPluginGet* In the recovered buffer, the command > :RecoverPluginGet < Will get all changes from the recovered swapfile put them in the buffer and finish diff mode off. *RecovePlugin-config* If you want Vim to automatically edit any file that is open in another Vim instance but is unmodified there, you need to set the configuration variable: g:RecoverPlugin_Edit_Unmodified to 1 like this in your |.vimrc| > :let g:RecoverPlugin_Edit_Unmodified = 1 < Note: This only works on Linux. If you do not want Vim to examine the existing swapfile and figure out things like whether the file is unmodified in another Vim process and to check the process ID, then you need to set the configuration variable g:RecoverPlugin_Examine_Swapfile to 1 like this in your |.vimrc| > :let g:RecoverPlugin_No_Check_Swapfile = 1 < If you want Vim to silently delete unmodified swapfiles that are not being edited in another session, set the variable g:RecoverPlugin_Delete_Unmodified Swapfile to 1 like this in your |.vimrc| > :let g:RecoverPlugin_Delete_Unmodified_Swapfile = 1 < Note: This only works on Linux. If you want Vim to always display the swap file exists message, regardless of whether the found swap file is different from the edited file, add this to your |.vimrc| > :let g:RecoverPlugin_Prompt_Verbose = 1 If not set, Vim will only prompt when it notices that the swap file differs from the file to be edited. *RecoverPlugin-misc* If your Vim was built with |+balloon_eval|, recover.vim will also set up an balloon expression that shows you which buffer contains the recovered version of your file and which buffer contains the unmodified on-disk version of your file if you move the mouse over the buffer. (See |balloon-eval|). If you have setup your 'statusline', recover.vim will also inject info about which buffer contains the on-disk version and which buffer contains the modified, recovered version. Additionally the buffer that is read-only will have a filename (|:f|) of something like 'original file (on disk-version)'. If you want to save that version, use |:saveas|. ============================================================================== 3. CVIM *cvim* cvim is a Python script (contributed by Marcin Szamotulski) that is distributed together with the recoverplugin. It is located in the contrib/ folder of the plugin source (or in the contrib/ directory of your $VIMRUNTIME/ path (e.g. usually in ~/.vim/contrib) if you have installed the vimball version of the plugin) Usage: cvim [-h] [-r] [-f] [-a] {directory} ... cvim is a Python script, which can be used in a terminal to clear the {directory} from |swapfile|s. Without any switches it finds all |swapfile|s then checks if a found |swapfile| is used by vim (using psutil python library). If it is not, then it reads the |swapfile| and if the content matches the corresponding file it delets it. You can get psutil from: http://code.google.com/p/psutil/ If a file has multiple |swapfile|s left you can exit vim with |:cq| to preserve them all on disk or you will be asked to delete them/step through them. These |swapfile|s are sorted by their modification time stamp (newest first). |cvim| works with python2.6, 2.7 and python3.3. The scripts accepts the following positional arguments: {directory} directory where to look for swap (by default current directory), it can be specified multiple times. optional arguments: -h, --help show help message and exit -r, -R, --recursive search directory recursively -f, --find only find and list |swapfile|s, it impiles -r -a, --ask ask before deleting swap files which do not differ from the file. Note: cvim might not work on Windows. ============================================================================== 4. Plugin Feedback *recover-feedback* Feedback is always welcome. If you like the plugin, please rate it at the vim-page: http://www.vim.org/scripts/script.php?script_id=3068 You can also follow the development of the plugin at github: http://github.com/chrisbra/Recover.vim Please don't hesitate to report any bugs to the maintainer, mentioned in the third line of this document. ============================================================================== 5. recover History *recover-history* 0.20: (unreleased) - Several fixes for |cvim| (contributed by Mateusz Jończyk, https://github.com/chrisbra/Recover.vim/pull/35, thanks!) - Don't assume vim when parsing Swap file dialog (contributed by Michael Reed, https://github.com/chrisbra/Recover.vim/pull/36, thanks!) - Check for existence of |v:progpath| before using it (reported by Dmytro Kolomoiets, https://github.com/chrisbra/Recover.vim/issues/37, thanks!) - Fix issue #38 (https://github.com/chrisbra/Recover.vim/issues/38, reported by PhilRunninger, thanks!) - If g:RecoverPlugin_Delete_Unmodified_Swapfile is set, delete unmodifed swapfiles that are not edited in another Vim buffer. (https://github.com/chrisbra/Recover.vim/issues/46, reported by Astara, thanks!) - Allow to always show the swap file exists dialog, even if the swap file does not differ from the file being edited (https://github.com/chrisbra/Recover.vim/issues/64, reported by damnskippy, thanks!) 0.19: Jan 15, 2015 "{{{1 - fix issue 29 (plugin always loaded autoload part, https://github.com/chrisbra/Recover.vim/issues/29, reported by Justin Keyes, thanks!) - fix issue 30 (remove needless 2 second sleep, https://github.com/chrisbra/Recover.vim/issues/30, reported by Justin Keyes, thanks!) - only reset swapfile option, if the current buffer has a name - |:RecoverPluginGet| to easily get the recovered version into your buffer and finish everything up (issue 31 https://github.com/chrisbra/Recover.vim/issues/31, reported by luxigo, thanks!) 0.18: Aug 14, 2013 "{{{1 - fix issue 19 (https://github.com/chrisbra/Recover.vim/issues/19, by replacing feedkeys("...\n") by feedkeys("...\", reported by vlmarek, thanks!) - fix issue 20 (https://github.com/chrisbra/Recover.vim/issues/20, (let vim automatically edit a file, that is unmodified in another vim instance, suggested by rking, thanks!) - merge issue 21 (https://github.com/chrisbra/Recover.vim/pull/21, create more usefule README.md file, contribted by Shubham Rao, thanks!) - merge issue 22 (https://github.com/chrisbra/Recover.vim/pull/22, delete BufReadPost autocommand contributed by Marcin Szamotulski, thanks!) - distribute |cvim| script (contributed by Marcin Szamotulski, thanks!) 0.17: Feb 16, 2013 "{{{1 - fix issue 17 (https://github.com/chrisbra/Recover.vim/issues/17 patch by lyokha, thanks!) - Use default key combinations in the dialog of the normal Vim dialog (adding only the Diff option) - Make sure, the process ID is shown 0.16: Nov 21, 2012 "{{{1 - Recovery did not work, when original file did not exists (issue 11 https://github.com/chrisbra/Recover.vim/issues/11 reported by Rking, thanks!) - By default, delete swapfile, if no differences found (issue 15 https://github.com/chrisbra/Recover.vim/issues/15 reported by Rking, thanks!) - reset 'swapfile' option, so that Vim by default creates .swp files (idea and patch by Marcin Szamotulski, thanks!) - capture and display |E325| message (and also try to figure out the name of the pid (issue 12 https://github.com/chrisbra/Recover.vim/issues/12) 0.15: Aug 20, 2012 "{{{1 - fix issue 5 (https://github.com/chrisbra/Recover.vim/issues/5 patch by lyokha, thanks!) - CheckSwapFileExists() hangs, when a swap file was not found, make sure, s:Swapname() returns a valid file name - fix issue 6 (https://github.com/chrisbra/Recover.vim/issues/6 patch by lyokha, thanks!) - Avoid recursive :redir call (https://github.com/chrisbra/Recover.vim/pull/8 patch by Ingo Karkat, thanks!) - Do not set 'bexpr' for unrelated buffers ( https://github.com/chrisbra/Recover.vim/pull/9 patch by Ingo Karkat, thanks!) - Avoid aborting the diff (https://github.com/chrisbra/Recover.vim/pull/10 patch by Ingo Karkat, thanks!) - Allow to directly delete the swapfile ( https://github.com/chrisbra/Recover.vim/issues/7 suggested by jgandt, thanks!) 0.14: Mar 31, 2012 "{{{1 - still some problems with issue #4 0.13: Mar 29, 2012 "{{{1 - fix issue 3 (https://github.com/chrisbra/Recover.vim/issues/3 reported by lyokha, thanks!) - Ask the user to delete the swapfile (issue https://github.com/chrisbra/Recover.vim/issues/4 reported by lyokha, thanks!) 0.12: Mar 25, 2012 "{{{1 - minor documentation update - delete swap files, if no difference found (issue https://github.com/chrisbra/Recover.vim/issues/1 reported by y, thanks!) - fix some small issues, that prevented the development versions from working (https://github.com/chrisbra/Recover.vim/issues/2 reported by Rahul Kumar, thanks!) 0.11: Oct 19, 2010 "{{{1 - use confirm() instead of inputdialog() (suggested by D.Fishburn, thanks!) 0.9: Jun 02, 2010 "{{{1 - use feedkeys(...,'t') instead of feedkeys() (this works more reliable, although it pollutes the history), so delete those spurious history entries - |RecoverPluginHelp| shows a small help message, about diff commands (suggested by David Fishburn, thanks!) - |RecoverPluginFinish| is a shortcut for |FinishRecovery| 0.8: Jun 01, 2010 "{{{1 - make :FinishRecovery more robust 0.7: Jun 01, 2010 "{{{1 - |FinishRecovery| closes the diff-window and cleans everything up (suggestion by David Fishburn) - DeleteSwapFile is not needed anymore 0.6: May 31, 2010 "{{{1 - |recover-feedback| - Ask to really open a diff buffer for a file (suggestion: David Fishburn, thanks!) - DeleteSwapFile to delete the swap file, that was used to create the diff buffer - change feedkeys(...,'t') to feedkeys('..') so that not every command appears in the history. 0.5: May 04, 2010 "{{{1 - 0r command in recover plugin adds extra \n Patch by Sergey Khorev (Thanks!) - generate help file with 'et' set, so the README at github looks prettier 0.4: Apr 26, 2010 "{{{1 - handle Windows and Unix path differently - Code cleanup - Enabled |:GLVS| 0.3: Apr 20, 2010 "{{{1 - first public verion - put plugin on a public repository (http://github.com/chrisbra/Recover.vim) 0.2: Apr 18, 2010 "{{{1 - Internal version, some cleanup, bugfixes for windows 0.1: Apr 17, 2010 "{{{1 - Internal version, First working version, using simple commands ============================================================================== Modeline: "{{{1 vim:tw=78:ts=8:ft=help:et:fdm=marker:fdl=0:norl