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

Re: How do I open a file from the Terminal into MacVim's current window?

Expand Messages
  • björn
    ... If you have the above preference set it is enough to simply use: open -a MacVim.app filename1 filename2 etc. If you have several windows open and want to
    Message 1 of 6 , Mar 24 2:30 PM
    • 0 Attachment
      On 24 March 2010 12:50, Andrew Stewart wrote:
      >> I have set the MacVim preference "Open files from applications" to "in
      >> the current window and set the arglist".  This give the behaviour I
      >> want when double-clicking in the Finder -- but doesn't for the
      >> Terminal.
      >
      > Aha: making use of the above, I can get the result I want.  In the
      > Terminal:
      >
      >    $ open "mvim://open?url=file:///path/to/file"
      >
      > And this respects the MacVim preference.
      >
      > If there's a more direct way I'd like to hear it...but for now this
      > will do.

      If you have the above preference set it is enough to simply use:

      open -a MacVim.app filename1 filename2

      etc.

      If you have several windows open and want to specify which one to open
      a file in you need to use the --remote and --servername arguments to
      the "mvim" script (see ":h mvim"), e.g.

      mvim --servername VIM --remote filename

      (The server name can be gleaned from the window title.)

      Björn

      --
      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

      To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
    • Andrew Stewart
      ... Oh yes, so it does. So to summarise, given a MacVim instance in the background, and focus in the Terminal: * `open -a MacVim.app filename1` will open
      Message 2 of 6 , Mar 25 10:47 AM
      • 0 Attachment
        On 24 Mar 2010, at 21:30, björn wrote:
        >> In the Terminal:
        >>
        >> $ open "mvim://open?url=file:///path/to/file"
        >>
        >> And this respects the MacVim preference.
        >>
        >> If there's a more direct way I'd like to hear it...but for now this
        >> will do.
        >
        > If you have the above preference set it is enough to simply use:
        >
        > open -a MacVim.app filename1 filename2
        >
        > etc.

        Oh yes, so it does.

        So to summarise, given a MacVim instance in the background, and focus
        in the Terminal:

        * `open -a MacVim.app filename1` will open filename1 in the existing
        MacVim window.
        * `mvim filename1` will open filename1 in a new MacVim window.

        Presumably the mvim URL handler opens in the existing (rather than a
        new) MacVim window because it wraps the `open -a` mechanism?


        > If you have several windows open and want to specify which one to open
        > a file in you need to use the --remote and --servername arguments to
        > the "mvim" script (see ":h mvim"), e.g.
        >
        > mvim --servername VIM --remote filename
        >
        > (The server name can be gleaned from the window title.)

        That's useful to know, thank you.

        Cheers,
        Andy

        -------
        http://airbladesoftware.com

        --
        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

        To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
      • björn
        ... Yes, using the open is like opening from Finder. MacVim works like this: each window runs its own Vim process. Opening a file from Finder results in the
        Message 3 of 6 , Mar 26 9:08 AM
        • 0 Attachment
          On 25 March 2010 18:47, Andrew Stewart wrote:
          >
          > So to summarise, given a MacVim instance in the background, and focus in the
          > Terminal:
          >
          > * `open -a MacVim.app filename1` will open filename1 in the existing MacVim
          > window.
          > * `mvim filename1` will open filename1 in a new MacVim window.
          >
          > Presumably the mvim URL handler opens in the existing (rather than a new)
          > MacVim window because it wraps the `open -a` mechanism?

          Yes, using the "open" is like opening from Finder.

          MacVim works like this: each window runs its own Vim process. Opening
          a file from Finder results in the MacVim app getting a request to open
          a file (mvim:// handler requests also end up here). At this point
          MacVim will look at your preferences and respect those. When opening
          a file from Terminal (with "mvim") you are actually starting a new Vim
          process manually and this process connects to the MacVim app which
          responds by opening up a new window. This is why "mvim" always opens
          a new window. (Maybe this is too much information, but there you go.)

          Björn

          --
          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

          To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
        • Andrew Stewart
          ... On the contrary, it s good to know exactly how this all works. Thanks for taking the time to type it all out. It makes perfect sense now. Regards, Andy
          Message 4 of 6 , Mar 26 10:07 AM
          • 0 Attachment
            On 26 Mar 2010, at 16:08, björn wrote:
            > MacVim works like this: each window runs its own Vim process. Opening
            > a file from Finder results in the MacVim app getting a request to open
            > a file (mvim:// handler requests also end up here). At this point
            > MacVim will look at your preferences and respect those. When opening
            > a file from Terminal (with "mvim") you are actually starting a new Vim
            > process manually and this process connects to the MacVim app which
            > responds by opening up a new window. This is why "mvim" always opens
            > a new window. (Maybe this is too much information, but there you go.)

            On the contrary, it's good to know exactly how this all works. Thanks
            for taking the time to type it all out.

            It makes perfect sense now.

            Regards,

            Andy Stewart
            ------
            http://airbladesoftware.com

            --
            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

            To unsubscribe from this group, send email to vim_mac+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
          Your message has been successfully submitted and would be delivered to recipients shortly.