3

I like running gVim in a single instance, i.e. a single gui window with separate tabs for each file I'm editing.

I also run a linux desktop environment that has multiple desktop workspaces. E.g. GNOME, KDE or Xfce.

I would like to have a single instance of gVim per desktop workspace.

I currently alias gvim to gvim --remote-tab-silent. Unfortunately this create a single instance (gui window) which has tabs for all of the files open in gVim from all of my workspaces.

As each workspace I use is for a different git branch it's easy to get confused as to which branch a file I'm editing is in from.

4
  • 3
    Can you just change your alias to gvim --remote-tab-silent --servername [Workspace name]?
    – Rich
    Commented Feb 7, 2020 at 12:15
  • (Not that it’s super relevant) but how do you manage to have each workspace be a different branch? Are you using git-worktree for that?
    – D. Ben Knoble
    Commented Feb 7, 2020 at 14:02
  • I have multiple git workspaces. Each of them is on a different branch. I work on each git 'workspace' in a separate desktop 'workspace'. [Sorry about overloading the term 'workspace'. Commented Feb 7, 2020 at 14:43
  • I haven't used --servername before. But this looks like it will work. Any idea how I find out the workspace name? I'll search for that. Commented Feb 10, 2020 at 11:58

1 Answer 1

1

Creating a function for this works

function gv () { 
  WS=`xprop -root -notype _NET_CURRENT_DESKTOP | awk '{print $3}'`;
  gvim --servername $WS --remote-tab-silent $@
 }

Note that tab completion doesn't work for me for the function so I alias something to this function.

xprop ... returns the workspace number in column 3 awk extracts just column 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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