I have configured Byobu to open a dozen text files at startup:

new-session -n memo /home/nico/bin/vim-my-memo.sh;
new-window -n client1 /home/nico/bin/vim-client1.sh;

It works well, but closing all vim sessions whenever I need to shut down my computer would take too much time, so I close the whole Byobu by clicking on the red X button at the upper left.

PROBLEM: When I reopen Byobu, all vim sessions are showing:

Found a swap file by the name "~/.memo.txt.swp"
          owned by: nico   dated: Fri Jul 17 21:18:38 2015
         file name: ~nico/memo.txt
          modified: no
         user name: nico   host name: nico
        process ID: 21813 (still running)
While opening file "/home/nico/memo.txt"
             dated: Fri Jul 17 21:08:32 2015

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /home/nico/memo.txt"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/home/nico/.memo.txt.
    to avoid this message.

Swap file "~/d/n/.memo.txt.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

QUESTION: How to avoid this?

Maybe Byobu could somehow send a kill signal to vim to make it exit properly?
Or maybe all that's needed is some vim configuration/trick?


Using set noswapfile in your vimrc file or files (or :set noswapfile otherwise) has some perhaps unwanted side effects, but does the trick from the vim side.

I don't know about byobu, but if you can customize it to send the quit signal 3 (kill -3 vimprocess) to all your vim processes, that would do the trick.

EDIT: The tmux plugin at https://github.com/jlipps/tmux-safekill will do what you want (and more: see the safekill.sh script for customization), without the drawbacks of set noswapfile.

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.