Loading ...
Sorry, an error occurred while loading the content.

12162Re: mvim: bring forward window/tab of already open window instead of Alert

Expand Messages
  • björn
    Mar 10, 2011
      On 10 March 2011 00:22, Eric Wing wrote:
      > On 3/7/11, björn <bjorn.winckler@...> wrote:
      >> On 6 March 2011 00:36, E. Wing wrote:
      >>> I use mvim a lot to open files. I often get into situations where I
      >>> have so many open files, I don't remember which I left open and which
      >>> I closed. And when I try to open an already open file, I get the
      >>> Alert: "Swap file "foo.swp" already exists!" and a bunch of options,
      >>> none of which brings the current open window/tab forward.
      >>> Is there a way to get mvim to bring forward the already open window or
      >>> tab of the file I request (assuming it is open)? And if the file isn't
      >>> already open, I would expect mvim to do what it currently does.
      >>> I looked at the --remote-tab-silent switch. It seems close to what I
      >>> want, but I don't want these things in new tabs, but windows when not
      >>> already open. It also seems to get confused if I have an additional
      >>> parameter like the line number:
      >>> mvim --remote-tab-silent-switch +60
      >>> Instead of jumping to line 60, it opens a second tab called +60.
      >>> Any suggestions?
      >> The only easy way to achieve this is to use "open -a MacVim filename"
      >> but that won't let you pass parameters.
      >> I don't have an easy solution if you need to pass parameters as well.
      >> The only thing I can think of is to write a script which queries all
      >> open Vim servers for a list of open filenames using --serverlist to
      >> get all Vim servers, then --remote-expr to query each server for open
      >> files.  If a file is found to be open, then raise that server with
      >> --remote-send.  This is done by MacVim, the relevant code is inside
      >> MMAppController.m -- search for "addVimInput" (which is basically
      >> --remote-send) and "evaluateVimExpression" (which is basically
      >> --remote-expr).
      > Is there any documentation on how to use expressions? I'm unfamiliar
      > with the concept/syntax.

      Expressions means "Vim script expressions". So you'll have to read up
      on scripting Vim. The reference is at ":h eval", the guide is at ":h
      usr_41". I believe all the scripts you need are in the source code I
      pointed you to (it can be a bit hard to "extract" however).

      > Out of curiosity, is the Scripting Bridge support robust enough to
      > attempt it that way? Is that a bad idea?

      Do you mean is it possible to use Apple Script to control MacVim?
      Then the answer is mostly no. You can do things like quit the app and
      change window size I believe, but that's about it. (I've never used


      You received this message from the "vim_mac" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 8 messages in this topic