On Thu, Jan 14, 2016 at 10:05 AM, Salman Halim <[email protected]> wrote:
> > > 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 . "')" ) ) > " 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>" ) > > " 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 > Just realized I put in a "Closematching" command in there. Oops! That -- basically (it's a little more complicated) -- executes 'tabdo window' and checks to see if the current file is the same the one passed in and executes 'q!' (quit without saving -- you may want to do an x, instead). -- Salman I, too, shall something make and glory in the making. -- -- 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.
