I use Linux and usually run Vim in a terminal. Lately, I've been using Vim's clientserver functionality to interact with Vim remotely. I'm wondering if there's a way to focus the terminal/Vim window when interacting with Vim in this way. For example, in one terminal I run Vim as:
$ vim --servername VIM
and in another terminal I call the following command to open a text file in the first terminal:
$ vim --remote /path/to/file.txt
This command is successful, but doesn't focus the first terminal. Note that I tested this in Arch Linux with both Gnome and i3 window manager, and with both
Also, I've tried using Vim's
foreground() command via
vim --remote-send ':call foreground()<CR>', as well as the
vim -f option. These commands didn't work for me, and based on Vim's documentation, I don't believe they should when Vim is run in a terminal. But please correct me if I'm wrong.
Additionally, I know that I could probably accomplish my goal by combining the Vim remote commands with a shell command that interacts with windows (e.g.
wmctrl). But I'm wondering if there's a better (and preferably native) way to do this.