UserPreferences

ApplicationNotes/VimNotes


1. Vim Notes

1.1. Stash Copy of File When Writing

The RT CLI client [WWW]loses your work if submission of your ticket is unsuccessful because it deletes the temp file which you were editing regardless. A work-around is to use Vim's autocommand facility to preserve a copy of the temp file, which you can then manually delete later (or, if you're using tmpfs, just let disappear on reboot). All it takes is the following addition to your .vimrc:
    autocmd BufWrite /tmp/rt.form.*  w! <afile>-preserve

The [WWW]BufWrite adds a hook for any files names /tmp/rt.form.* that runs every time the file is written. The [WWW]<afile> is a Vim variable-like that is substituted for the name of the current file name; the -preserve is added to the end to differentiate it from the original file, which is deleted by the RT client. It is necessary to use w! instead of just w, otherwise you get an error after the first write due to the destination file already existing.