2016-01-14 18:05 GMT+03:00 Salman Halim <[email protected]>:
>
>
> On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov <
> [email protected]> wrote:
>
>
>>
>>
>> 2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <
>> [email protected]>:
>>
>>> Is it possible to detach the current tab in a gvim session into a
>>> separate gvim window? Something akin to what firefox can do with tabs?
>>>
>>> Once the tab is separated, can I dock it back into the original gvim
>>> window session?
>>>
>>
>> Firefox manages multiple X windows by one instance, and it was
>> originally developed for graphical environment. Gvim has one process (and
>> one instance) per one X window, doing no management of its windows. Vim
>> originally developed for terminals and many GUI features are missing simply
>> because they are not possible in terminal (though still there are such
>> features, there are not much).
>>
>> I would though ask why do you need this functionality in first place. I
>> never had enough tabs open to want detaching, perhaps you are misusing this
>> feature.
>>
>>
>
> There is a macro in the runtime directory/macros called editexisting.vim
> which causes a file already being edited in another session of Vim to be
> brought to the foreground if you try to edit it again in another session. I
> modified it to, instead, close the other one and allow me to keep the new
> instance, instead. Perhaps you can modify it to do what you need. Note that
> I also use <S-F4> to copy the entire filepath of the current file to the
> system clipboard and <C-F4> to open the file currently on the current
> clipboard. So,
>
>
> 1. Go to the file you wish to detach and hit <S-F4>.
> 2. Go to the other Vim session (open one).
> 3. Hit <C-F4> to open it here and close the original.
>
> The mappings and script (I use Windows exclusively so your mapping may
> need to be tweaked):
>
> nmap <s-f4> :let @*=substitute(expand("%:p"), '/', '\\', 'g')<cr>:echo
> 'Copied "' . @* . '"'<cr>
>
> nmap <c-f4> :execute 'sp ' . escape(@*, " ")<cr>
>
>
> function! CloseBufferElsewhere( name )
> let filename = substitute( a:name, "'", "''", "g" )
> let servers = split( serverlist(), "\n" )
>
> for server in servers
> if ( server ==? v:servername )
> continue
> endif
>
> if ( remote_expr( server, "bufloaded('" . filename . "')" ) )
>
This should be using `string()`, *not* `"'" . filename "'"`.
> " SALMAN: If multiple files by the same name are found, they will
> all be closed. Sometimes, two files with the same name but in different
> directories are found;
> " SALMAN: this should be addressed if it occurs too much.
> "
> " SALMAN: Last occurrence was on Tuesday, November 15, 2011.
> call remote_send( server, ":Closematching " . fnamemodify( filename,
> ":t" ) . "\<cr>" )
>
And this should use `fnameescape()` and, probably, unknown additional
hacks to make file names with newline inside work. Though actually depends
on :Closematching definition, maybe it is incorrect in first place and
`fnameescape()` will not help.
Why did not you simply use a function and remote_expr instead? This looks
like there will be numerous problems than need solution:
1. Mode: what if server current mode is not normal mode?
2. Count: what if you have accidentally in server typed `2` before calling
this command from remote?
3. Escaping: depends on the definition of the command.
4. Escaping 2: examples like
:echo remote_send("gvim", ":sleep 10 | echo ".
\ 'server2client(expand("<client>"), "HELLO")<CR>')
in help suggest that file named `<CR>` will be interpreted as carriage
return and not as literal `<CR>`. So there needs to be additional level of
escaping.
>
> " If another server was found, it should've been closed and this
> file edited here now.
> return 'e'
> endif
> endfor
>
> " Ask the user what to do (a swap file exists, but no actual Vim
> instance was found).
> return ''
> endfunction
>
> augroup CloseBufferElsewhere
> au! SwapExists * let v:swapchoice = CloseBufferElsewhere( expand(
> "<afile>:p" ) )
> augroup END
>
> Hope this brings you closer,
>
>
> Salman
>
> --
> --
> You received this message from the "vim_use" 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
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
You received this message from the "vim_use" 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
---
You received this message because you are subscribed to the Google Groups
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.