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

Re: Auto-raise existing Vim window on attempt to re-edit?

Expand Messages
  • Steve Hall
    From: Valery Kondakoff, Nov 4, 2003 10:17 AM ... You should find that the autocmds I included accomplish the same task without having to pass the function call
    Message 1 of 9 , Nov 4, 2003
    • 0 Attachment
      From: Valery Kondakoff, Nov 4, 2003 10:17 AM
      >
      > Hello, Steve!
      >
      > Tuesday, October 28, 2003, 11:02:04 PM, you wrote:
      >
      > > If you're by chance interested in maintaining only a single
      > > instance, I use a system that maintains a single instance of gVim
      > > in all cases, on both Windows and Linux. Below is an (untested)
      > > abbreviation of the function I use to accomplish this:
      > >
      > > ---------------------------------------------------------------
      > > function! Singleserver()
      > > ---------------------------------------------------------------
      >
      > I'm very interested in maintaining a single GVIM instance. Two or
      > three weeks ago was asking for help on this topic in a general VIM
      > mailing list.
      >
      > Now I tryed Singleserver() function and it seems to work pretty well.
      > After putting your function in my _vimrc I'm launching GVIM like this:
      >
      > gvim.exe "+call Singleserver()" filename
      >
      > Is this usage correct or am I missing something?

      You should find that the autocmds I included accomplish the same task
      without having to pass the function call on startup.


      > I'm asking this because your function seems to work pretty well,
      > except that when I'm opening a file using this command (gvim.exe
      > "+call Singleserver()" test.txt) I'm receiving 'Swap file
      > test.txt.swp already exists' message. The file loads properly if I
      > choose 'Edit anyway' button. (I'm using GVIM 6.2, WinXP Pro).
      >
      > If there is a way to eliminate 'Swap already exists' message?

      I've not been able to find a way, other than turning off swap files
      with :set noswapfile. You could probably derive some very nasty hack
      where it is only momentarily turned off as the two servers are merged,
      passing the file info back and forth a few times, but it seems like
      too much overhead for me.

      Besides Vim never crashes, so who needs swap files? :)

      --
      Steve Hall [ digitect@... ]
    • Valery Kondakoff
      Hello, Steve! Tuesday, November 4, 2003, 6:43:56 PM, you wrote: SH You should find that the autocmds I included accomplish the same task SH without having to
      Message 2 of 9 , Nov 5, 2003
      • 0 Attachment
        Hello, Steve!

        Tuesday, November 4, 2003, 6:43:56 PM, you wrote:

        SH> You should find that the autocmds I included accomplish the same task
        SH> without having to pass the function call on startup.

        Sorry, it seems I can't find no autocommands in the function that you
        post. There is the entire function:

        -----
        function! Singleserver()
        " always merge a new instance of Vim into a (single) existing one

        " don't use in terminal!
        if !has("gui_running")
        return
        endif

        " if this isn't the primary server
        if v:servername !=? "GVIM"

        " compose command to re-open this file if real
        if bufexists(bufnr("%"))
        " get file name/path
        let myfile = expand("%:p")
        " reverse backslashes (Windows and Unix compatibility)
        let myfile = substitute(myfile, '\\', '/', 'g')
        " escape spaces
        let myfile = escape(myfile, ' ')
        " command to edit current file and maintain position
        let mycmd = '<C-o>:edit +' . line('.') . ' ' . myfile . '<CR>'
        " compose command to open a new buffer
        else
        let mycmd = '<C-o>:enew<CR>'
        endif

        " pass file open/position command to primary server
        call remote_send('GVIM', mycmd)
        " call primary server to foreground
        call remote_foreground('GVIM')
        " quit this server
        confirm qall

        end

        endfunction
        ----

        >>
        >> If there is a way to eliminate 'Swap already exists' message?

        SH> I've not been able to find a way, other than turning off swap files
        SH> with :set noswapfile. You could probably derive some very nasty hack
        SH> where it is only momentarily turned off as the two servers are merged,
        SH> passing the file info back and forth a few times, but it seems like
        SH> too much overhead for me.

        Yes, thank you for an explanation.

        SH> Besides Vim never crashes, so who needs swap files? :)

        :)

        --
        Best regards,
        Valery mailto:strauss@...

        PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

        np: 01 - Горький Ангел [stopped]
      • Steve Hall
        From: Valery Kondakoff, Nov 5, 2003 10:37 AM ... Please refer to my first post: http://groups.yahoo.com/group/vim/message/44631 -- Steve Hall [
        Message 3 of 9 , Nov 5, 2003
        • 0 Attachment
          From: Valery Kondakoff, Nov 5, 2003 10:37 AM
          > Tuesday, November 4, 2003, 6:43:56 PM, you wrote:
          > >
          > > You should find that the autocmds I included accomplish the same
          > > task without having to pass the function call on startup.
          >
          > Sorry, it seems I can't find no autocommands in the function that
          > you post.

          Please refer to my first post:

          http://groups.yahoo.com/group/vim/message/44631


          --
          Steve Hall [ digitect@... ]
        Your message has been successfully submitted and would be delivered to recipients shortly.