Friday, January 6, 2023

Re: complement to T



On Fri, Jan 6, 2023 at 1:12 AM Enan Ajmain <3nan.ajmain@gmail.com> wrote:
On Thu, 5 Jan 2023 21:32:24 -0800 (PST)
scowles@ckhb.org wrote:
> is there a complement to <ctrl-w>T?
>
> i do file diffs in a split tab page and occassionally move one of the
> windows to a new tab page.  is there any existing mechanism for
> moving a file in a tab page to an empty window in another tab page?

There is no existing mechanism, no.  And I don't think there is any
concept of an "empty window" in Vim.  I guess you're talking about
':new' windows with unnamed buffer ([No Name]).

In any case, you should be able to build yourself a function.

  1. Get current buffer number (see ':h bufnr'). Say it's "3".
  2. Move to the tab where you want to move the buffer (':norm! <n>gt'),
     where "<n>" is an integer.
  3. Split a window and open the buffer "3" (':split | b3').
  4. Return.

--
Enan

I use the following mappings to create a new tab and move the current buffer from here to there or to copy it to there (so that it remains here AND shows up in the new tab, also):

" Moves the current buffer to a new tab; I can type this faster than <c-w>T
nmap <leader>nt <c-w>T
" Opens a new tab with the current buffer in it, leaving the current buffer in the current tab as well.
nmap <leader>nT :sp<cr><leader>nt

If you want to move the current file to an already existing tab, then I included MoveToTab and CopyToTab commands in my tab manager (https://www.vim.org/scripts/script.php?script_id=3536) that takes a single parameter: the number of the destination tab, $ to mean the last tab, n to mean the next tab or p to mean the previous tab.

I hope one of these does what you want.

All the best,

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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEfJbq4AGN-VT9a1xox6be8FPxDfxnPVtU4_JFe-Rw3T_Q%40mail.gmail.com.

No comments:

Post a Comment