Using vim-autoswap in KDE konsole

When working on multiple terminals it happens that you want to edit a file which is already open in another vim session. In thise case vim shows a message like the following:

Found a swap file by the name ".vimrc.swp"
owned by: gergap   dated: Sun Aug 17 19:41:16 2014
file name: ~gergap/vim/.vimrc
modified: no
user name: gergap   host name: tux
process ID: 3439 (still running)
While opening file ".vimrc"
dated: Sun Aug 17 16:56:37 2014

(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 .vimrc”
to recover the changes (see “:help recovery”).
If you did this already, delete the swap file “.vimrc.swp”
to avoid this message.

Swap file “.vimrc.swp” already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

Another reason for this could be that you didn’t exited vim properly, maybe due to power loss or, becaused you killed vim, or even because of a crash (which I never had with vim yet).
Anyway, if it’s an orphaned swap file you probably want to revover the latest changes. If you have the file currently open the best thing would be to switch over to that session. Damian Conway’s vim-autoswap does exactly this.
See for more information on that plugin.

However for switching to another terminal with the correct vim session, it needs to interact with your window manager, which is platform dependent. vim-autoswap was originally written for Max OS X, then it was ported to Linux. Here it uses wmctrl to control the window manager. The only missing part is that the window must contain the right filename so that vim-autoswap can switch over using wmctrl. This does not work out-of-the-box using vim in KDE konsole.
So I created a plugin for that. It’s named vim-konsole – surprise, surprise 😉

The recommended why for installing that is using vim-pathogen. If you don’t know that have a look at Then simple install vim-konsole using git.

cd ~/.vim/bundle
git clone

Restart vim and you are done. The Konsole window should now show the filename of the current file you are editing. This way also vim-autoswap should be able to switch to the correct terminal when opening the same file on another terminal.

0 Responses to “Using vim-autoswap in KDE konsole”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: