detach current tab into a separate window

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

detach current tab into a separate window

kamaraju kusumanchi
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?

thanks
raju
--
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Christian Brabandt
On Do, 14 Jan 2016, kamaraju kusumanchi wrote:

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

This is not possible.

Best,
Christian
--
Wenige Dinge auf Erden sind lästiger als die stumme Mahnung, die von
einem guten Beispiel ausgeht.
                -- Mark Twain (eigl. Samuel Langhorne Clemens)

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Nikolay Aleksandrovich Pavlov
In reply to this post by kamaraju kusumanchi


2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <[hidden email]>:
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.
 

thanks
raju
--
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog

--
--
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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Salman Halim


On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:




2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <[hidden email]>:
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

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Salman Halim


On Thu, Jan 14, 2016 at 10:05 AM, Salman Halim <[hidden email]> wrote:


On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:




2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <[hidden email]>:
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Nikolay Aleksandrovich Pavlov
In reply to this post by Salman Halim


2016-01-14 18:05 GMT+03:00 Salman Halim <[hidden email]>:


On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:




2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <[hidden email]>:
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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Salman Halim


On Thu, Jan 14, 2016 at 10:41 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:


2016-01-14 18:05 GMT+03:00 Salman Halim <[hidden email]>:


On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:




2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <[hidden email]>:
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?


...

    if ( remote_expr( server, "bufloaded('" . filename . "')" ) )


​This should be using `string()`, *not* `"'" . filename "'"`.​

Fair enough. However, if you look at the comment a few lines below, I last added a comment to it in 2011. I don't remember when I last made any actual code changes to this. (Probably soon after editexisting.vim came around.) If I'd had trouble with it, I would've probably addressed it sooner. (I also suggested modifying it to do what is needed in my original response; this includes improvements.)


 

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

I haven't shared this function before, so the issues you raise haven't come up. I don't have any files that contain relatively uncommon filename characters such as newlines (spaces, yes: Windows, after all) so never had to address it.
 

Why did not you simply use a function and remote_expr instead?

I thought about it, but then figured it would offend you more this way. :) Also, I probably knew a bit less about the Vim API five (or more) years ago.
 
This looks like there will be numerous problems than need solution:

For various reasons, however, I have managed to avoid most of the pitfalls. Sadly, this good fortune did not extend to the US$1.5B lottery from yesterday.
 

1. Mode: what if server current mode is not normal mode?

In my workflow, I don't usually leave Vim sessions in 'not normal mode'. I'm sure it happens, but I don't really do the 'open already opened file' bit very often. Probably been lucky so far.

2. Count: what if you have accidentally in server typed `2` before calling this command from remote?

Hasn't happened yet. But it's Windows: I'd probably just reboot. :)
 
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.

Certainly, if you experience filenames with special characters in them, you may need to make this function significantly more robust than I have it here.

If you would care to fix the problems herein, I and Kamaraju would appreciate it. My only defense of sharing this feeble implementation is that all the other responses were around the lines of "can't be done" and "your workflow is wrong" (slightly paraphrasing your original response), which, while no doubt resulting in a long hard look at the life decisions by Kamaraju that led to his flawed workflow, don't really get him much closer to a solution that actually has a go at answering his question.

Regards,

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Nikolay Aleksandrovich Pavlov


2016-01-14 20:20 GMT+03:00 Salman Halim <[hidden email]>:


On Thu, Jan 14, 2016 at 10:41 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:


2016-01-14 18:05 GMT+03:00 Salman Halim <[hidden email]>:


On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov <[hidden email]> wrote:




2016-01-14 8:23 GMT+03:00 kamaraju kusumanchi <[hidden email]>:
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?


...

    if ( remote_expr( server, "bufloaded('" . filename . "')" ) )


​This should be using `string()`, *not* `"'" . filename "'"`.​

Fair enough. However, if you look at the comment a few lines below, I last added a comment to it in 2011. I don't remember when I last made any actual code changes to this. (Probably soon after editexisting.vim came around.) If I'd had trouble with it, I would've probably addressed it sooner. (I also suggested modifying it to do what is needed in my original response; this includes improvements.)


 

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

I haven't shared this function before, so the issues you raise haven't come up. I don't have any files that contain relatively uncommon filename characters such as newlines (spaces, yes: Windows, after all) so never had to address it.
 

Why did not you simply use a function and remote_expr instead?

I thought about it, but then figured it would offend you more this way. :) Also, I probably knew a bit less about the Vim API five (or more) years ago.
 
This looks like there will be numerous problems than need solution:

For various reasons, however, I have managed to avoid most of the pitfalls. Sadly, this good fortune did not extend to the US$1.5B lottery from yesterday.
 

1. Mode: what if server current mode is not normal mode?

In my workflow, I don't usually leave Vim sessions in 'not normal mode'. I'm sure it happens, but I don't really do the 'open already opened file' bit very often. Probably been lucky so far.

2. Count: what if you have accidentally in server typed `2` before calling this command from remote?

Hasn't happened yet. But it's Windows: I'd probably just reboot. :)
 
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.

Certainly, if you experience filenames with special characters in them, you may need to make this function significantly more robust than I have it here.

If you would care to fix the problems herein, I and Kamaraju would appreciate it. My only defense of sharing this feeble implementation is that all the other responses were around the lines of "can't be done" and "your workflow is wrong" (slightly paraphrasing your original response), which, while no doubt resulting in a long hard look at the life decisions by Kamaraju that led to his flawed workflow, don't really get him much closer to a solution that actually has a go at answering his question.

There is such a think as “XY problem”: when one asks for a solution for a problem that is a result of encountering another problem which may have more optimal solution, so answering the original question may actually be worthless.

But specifically regarding tabs there is one big problem: almost in every other application that has tabs one tab is bound to one URI (file, page, whatever). In Vim tab has absolutely nothing to do with any URIs: it is a viewport that contains a collection of windows. There is *no* strict connection to buffers. (There is even no direct connection: tabs directly contain only windows and only windows show (not contain) buffers in turn.) So if a person is asking something strange about tabs then 90% he is trying to use them in a way they were not designed to be used.

// Based on your second (not first) message in this thread I even thought that you may have the same problem: code is not suspicious, but “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).” is.

Basically in this case there are four major possibilities I see:

1. OP is trying to open some buffer in another Vim instance: it is better to examine workflow and, probably, change it. This is also invalid use of tabs.
2. OP is opening two projects in one Vim instance and wants to migrate them between WM windows: migrating this is far, far more complicated then your code, but probably one can use sessions with some hacks around them. Again it is better to inspect workflow, maybe plugins for working with projects will serve better. This is one of the use-cases tabs were developed for.
3. OP has one project in both tabs, but for some reason wants one of the tabs separate. Depending on the reason, most likely, solution may be found which keeps one Vim instance and still save the workflow. (Unlike second case tabs are used like “here I write the code and here I do debugging”. I personally sometimes have “here I work on one part of the project and here on another” (tabs are preferred over plain buffer switching here because each tab contains two to four windows showing different places (possibly in different buffers) of these parts). This is also one of the intended use-cases.)
4. OP is just wondering or is implicitly suggesting new functionality. Nothing needs to be done in this case.

In any case original request *cannot* be solved with the current codebase. So to give OP anything more meaningful then the very first answer on this thread OP should tell us why does he need this.

 

Regards,

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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Charles E Campbell Jr
In reply to this post by kamaraju kusumanchi
kamaraju kusumanchi wrote:
> 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?
>
You could try :Detach, which is available from
http://www.drchip.org/astronaut/vim/index.html#DETACH .

Note:

* The code will handle multiple windows open in one tab by duplicating
them in a new instance of gvim.
* One must have two or more tabs open to :Detach a tab
* One must have gvim available as an executable
* Two separate, independent instances of vim result: they do not share
variables, functions, etc.

Regards,
Chip Campbell

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

kamaraju kusumanchi
In reply to this post by Nikolay Aleksandrovich Pavlov
On Thu, Jan 14, 2016 at 8:44 AM, Nikolay Aleksandrovich Pavlov
<[hidden email]> wrote:
>
> 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).
>

So if a feature is useful in the graphical version (i.e. gvim) but is
not doable in the console vim, it wont be implemented? That argument
seems a bit backward. From a user perspective, they are two different
programs and it is ok to have a feature in one but in the other.

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

When I code in large C++ projects, I have many tabs open in one gvim
window. This window spans across one whole monitor. Now when writing
new code to call a function, I want to split two tabs from this window
and move them to the second monitor. These tabs typically contain the
header file, another C++ file where a function was used before. This
way I can look at the API, sample usage and add code in the current
window.

thanks
raju
--
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Benjamin Fritz
On Thursday, January 14, 2016 at 7:15:02 PM UTC-6, kamaraju kusumanchi wrote:
>
> When I code in large C++ projects, I have many tabs open in one gvim
> window. This window spans across one whole monitor. Now when writing
> new code to call a function, I want to split two tabs from this window
> and move them to the second monitor. These tabs typically contain the
> header file, another C++ file where a function was used before. This
> way I can look at the API, sample usage and add code in the current
> window.
>

Then perhaps, a simple :vsplit or :split command would serve your use-case? Or a :sb or :vert sb if the file is already open?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

kamaraju kusumanchi
On Thu, Jan 14, 2016 at 11:19 PM, Ben Fritz <[hidden email]> wrote:

> On Thursday, January 14, 2016 at 7:15:02 PM UTC-6, kamaraju kusumanchi wrote:
>>
>> When I code in large C++ projects, I have many tabs open in one gvim
>> window. This window spans across one whole monitor. Now when writing
>> new code to call a function, I want to split two tabs from this window
>> and move them to the second monitor. These tabs typically contain the
>> header file, another C++ file where a function was used before. This
>> way I can look at the API, sample usage and add code in the current
>> window.
>>
>
> Then perhaps, a simple :vsplit or :split command would serve your use-case? Or a :sb or :vert sb if the file is already open?
>

I am aware of :vsplit, :split. They are not sufficient. They split the
file in the current window. I want these to be new windows on the
other monitor as the current window already spans one monitor and I do
not want to change that view.

thanks
raju
--
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

kamaraju kusumanchi
In reply to this post by Charles E Campbell Jr
On Thu, Jan 14, 2016 at 3:29 PM, Charles E Campbell
<[hidden email]> wrote:

> kamaraju kusumanchi wrote:
>> 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?
>>
> You could try :Detach, which is available from
> http://www.drchip.org/astronaut/vim/index.html#DETACH .
>
> Note:
>
> * The code will handle multiple windows open in one tab by duplicating
> them in a new instance of gvim.
> * One must have two or more tabs open to :Detach a tab
> * One must have gvim available as an executable
> * Two separate, independent instances of vim result: they do not share
> variables, functions, etc.
>

Thank you Chris. I will give this a try.

raju

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

kamaraju kusumanchi
On Fri, Jan 15, 2016 at 12:29 AM, kamaraju kusumanchi
<[hidden email]> wrote:

> On Thu, Jan 14, 2016 at 3:29 PM, Charles E Campbell
> <[hidden email]> wrote:
>> kamaraju kusumanchi wrote:
>>> 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?
>>>
>> You could try :Detach, which is available from
>> http://www.drchip.org/astronaut/vim/index.html#DETACH .
>>
>> Note:
>>
>> * The code will handle multiple windows open in one tab by duplicating
>> them in a new instance of gvim.
>> * One must have two or more tabs open to :Detach a tab
>> * One must have gvim available as an executable
>> * Two separate, independent instances of vim result: they do not share
>> variables, functions, etc.
>>
>
> Thank you Chris. I will give this a try.
>

When I tried to detach fileB.txt from the gvim window started by
  gvim -p fileA.txt fileB.txt

there is a warning window saying
  Swap file ".fileB.txt.swp" already exists!
the buttons below asks the user to choose one of "Open Read-Only",
"Edit anyway", "Recover", "Quit", "Abort"

Can you fix this?

thanks
raju
--
Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Charles Campbell
In reply to this post by kamaraju kusumanchi
kamaraju kusumanchi wrote:
> window. This window spans across one whole monitor. Now when writing
> new code to call a function, I want to split two tabs from this window
> and move them to the second monitor. These tabs typically contain the
> header file, another C++ file where a function was used before. This
> way I can look at the API, sample usage and add code in the current
> window. thanks raju
Hello:

May I assure you that, using vim terminology which seems apropos since
we're talking about vim, that you do not have a vim window spanning the
whole monitor containing tabs.  One may have several tabs; each tab
takes up the entirety of vim's display excepting: tab choice line, gui
icon line, and commands/status line(s).  Each tab may hold a
multiplicity of windows, NOT vice versa.  Hoping to straighten this out
before confusion sets in.

Regards,
Chip Campbell



--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Charles E Campbell Jr
In reply to this post by kamaraju kusumanchi
kamaraju kusumanchi wrote:

> On Fri, Jan 15, 2016 at 12:29 AM, kamaraju kusumanchi
> <[hidden email]> wrote:
>> On Thu, Jan 14, 2016 at 3:29 PM, Charles E Campbell
>> <[hidden email]> wrote:
>>> kamaraju kusumanchi wrote:
>>>> 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?
>>>>
>>> You could try :Detach, which is available from
>>> http://www.drchip.org/astronaut/vim/index.html#DETACH .
>>>
>>> Note:
>>>
>>> * The code will handle multiple windows open in one tab by duplicating
>>> them in a new instance of gvim.
>>> * One must have two or more tabs open to :Detach a tab
>>> * One must have gvim available as an executable
>>> * Two separate, independent instances of vim result: they do not share
>>> variables, functions, etc.
>>>
>> Thank you Chris. I will give this a try.
>>
> When I tried to detach fileB.txt from the gvim window started by
>   gvim -p fileA.txt fileB.txt
>
> there is a warning window saying
>   Swap file ".fileB.txt.swp" already exists!
> the buttons below asks the user to choose one of "Open Read-Only",
> "Edit anyway", "Recover", "Quit", "Abort"
>
> Can you fix this?
>
Just tried this:

gvim -u NONE -N -p fileA.txt fileB.txt
:so [path]/Detach.vim
:Detach

and it worked correctly without any messages.  The message you got
appears when you hold the file open in another instance of gvim and,
really, you don't want not to have it.  Its telling you that changes
made to the file in one instance of gvim won't necessarily be reflected
in the other instance.  Remember, the :Detach command starts up a new
instance of gvim; its not a separate thread sharing the same memory.
Vim does not support that.

Regards,
Chip Campbell

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

kamaraju kusumanchi
On Fri, Jan 15, 2016 at 2:13 PM, Charles E Campbell
<[hidden email]> wrote:

>>>
>> When I tried to detach fileB.txt from the gvim window started by
>>   gvim -p fileA.txt fileB.txt
>>
>> there is a warning window saying
>>   Swap file ".fileB.txt.swp" already exists!
>> the buttons below asks the user to choose one of "Open Read-Only",
>> "Edit anyway", "Recover", "Quit", "Abort"
>>
>> Can you fix this?
>>
> Just tried this:
>
> gvim -u NONE -N -p fileA.txt fileB.txt
> :so [path]/Detach.vim
> :Detach
>
> and it worked correctly without any messages.  The message you got
> appears when you hold the file open in another instance of gvim and,
> really, you don't want not to have it.  Its telling you that changes
> made to the file in one instance of gvim won't necessarily be reflected
> in the other instance.  Remember, the :Detach command starts up a new
> instance of gvim; its not a separate thread sharing the same memory.
> Vim does not support that.
>

That is weird! It pops up the swap file exists error window even with
"gvim -u NONE -N -p fileA.txt fileB.txt". I am using vim 7.4.576 on
Debian Jessie.

raju

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: detach current tab into a separate window

Charles E Campbell Jr
You may have an errant swap file hanging around, possibly from an earlier abnormal termination.

C Campbell

> On Jan 15, 2016, at 11:05 PM, kamaraju kusumanchi <[hidden email]> wrote:
>
> On Fri, Jan 15, 2016 at 2:13 PM, Charles E Campbell
> <[hidden email]> wrote:
>>>>
>>> When I tried to detach fileB.txt from the gvim window started by
>>>  gvim -p fileA.txt fileB.txt
>>>
>>> there is a warning window saying
>>>  Swap file ".fileB.txt.swp" already exists!
>>> the buttons below asks the user to choose one of "Open Read-Only",
>>> "Edit anyway", "Recover", "Quit", "Abort"
>>>
>>> Can you fix this?
>>>
>> Just tried this:
>>
>> gvim -u NONE -N -p fileA.txt fileB.txt
>> :so [path]/Detach.vim
>> :Detach
>>
>> and it worked correctly without any messages.  The message you got
>> appears when you hold the file open in another instance of gvim and,
>> really, you don't want not to have it.  Its telling you that changes
>> made to the file in one instance of gvim won't necessarily be reflected
>> in the other instance.  Remember, the :Detach command starts up a new
>> instance of gvim; its not a separate thread sharing the same memory.
>> Vim does not support that.
>>
>
> That is weird! It pops up the swap file exists error window even with
> "gvim -u NONE -N -p fileA.txt fileB.txt". I am using vim 7.4.576 on
> Debian Jessie.
>
> raju
>
> --
> --
> 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 [hidden email].
> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.