1

I have been trying to setup the shell version of vim to save any changed files when the shell window loses focus.

Following these instructions does not work.

Even though I am using OS X, I figure this may be something that affects vim running on Linux as well. Could be wrong, but I thought I'd also try on here as well as apple.stackexchange.com.

Am I to assume that maybe the reason why this does not work for a command line version of vim is because it's only intended to work with GUI versions, i.e. MacVim?

Is there a way to get this to work for a shell version of vim?

I'm using the latest version of vim available in homebrew.

3

From :h FocusLost:

FocusLost                       When Vim lost input focus.  Only for the GUI
                                version and a few console versions where this
                                can be detected.  May also happen when a
                                dialog pops up.

*nix (including OS X) terminals do not make their focus status known to any applications run within them so this will not work there, and indeed there's no way to make it work.

  • D'oh! Thank you Ignacio. I guess that the Homebrew version of vim that I am using falls under the category which you quoted: "few console versions where this is detected". – Diego Barros Mar 19 '12 at 4:24
0

If your goal is to prevent losing code maybe backup files could help you.

set backup                    " keep a backup after overwriting a file
set backupdir^=/tmp//         " list of directories to put backup files in

I have it in my .muttrc, it stores backup files until restarting the Mac in /tmp/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.