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

Alternate Tab

Expand Messages
  • Jeenu
    Hi, I wonder whether there is a command which would open alternate tab, similar to CTRL-^ for alternate buffer. This would be particularly useful when working
    Message 1 of 5 , Mar 2 9:32 PM
    • 0 Attachment
      Hi,

      I wonder whether there is a command which would open alternate tab,
      similar to CTRL-^ for alternate buffer. This would be particularly
      useful when working with 2 tabs most of the time. It's a bit painful
      to use multiple 'gt' and 'gT', unless they are placed next to each
      other using ':tabm'

      Thanks
      Jeenu
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Sadarax
      I do not know of anything different than the keys you have mentioned. But you can always map different keys to these functions. Here are some of my mappings
      Message 2 of 5 , Mar 3 12:48 AM
      • 0 Attachment
        I do not know of anything different than the keys you have mentioned.

        But you can always map different keys to these functions. Here are some of my mappings from my .vimrc file:

        " Make a new tap with CTRL+t
        :nmap <C-t> :tabnew<cr>
        :imap <C-t> <ESC>:tabnew<cr>

        " Go to the next tab with a key press while in navigation mode
        :nmap <tab> :tabnext<cr>

        " Go to previous tab with Shift+h and next tab with Shift+l in navigation mode
        :nmap <S-h> gT
        :nmap <S-l> gt

        " Move to next tab while within insert mode
        :imap <C-E> <ESC>:tabnext<cr>a

        And those this is not related to what you want, I often use this to spawn a new tab (or Explorer window).

        " Run Explorer in a new Tab
        imap <F1> <Esc>:call RunExplorer() <CR>
        cmap <F1> :call RunExplorer() <CR>
        nmap <silent> <F1> :call RunExplorer() <CR>
        function! RunExplorer()
          if expand("%") != ""
            tabnew
          endif
          Explore
        endfunction

        I hope that helps.

        On Sun, Mar 2, 2008 at 9:32 PM, Jeenu <jeenuv@...> wrote:

        Hi,

        I wonder whether there is a command which would open alternate tab,
        similar to CTRL-^ for alternate buffer. This would be particularly
        useful when working with 2 tabs most of the time. It's a bit painful
        to use multiple 'gt' and 'gT', unless they are placed next to each
        other using ':tabm'

        Thanks
        Jeenu




        --
        How sad it would be to live a life less wonderful, if only because one were afraid of a little hard work. If you shy away from challenges, you shy away from some of the greatest achievements in life.
        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---

      • A.Politz
        ... Search for a thread called tab toggle . -ap -- ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use
        Message 3 of 5 , Mar 3 2:32 AM
        • 0 Attachment
          Jeenu wrote:

          >Hi,
          >
          >I wonder whether there is a command which would open alternate tab,
          >similar to CTRL-^ for alternate buffer.
          >
          >
          Search for a thread called 'tab toggle'.

          -ap


          --
          :wq


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Benjamin Fritz
          ... I used to use CTRL-T for new tab, but then I realized that CTRL-T is jump back from tag by default. So, if navigating help files, you can jump back after
          Message 4 of 5 , Mar 3 7:50 AM
          • 0 Attachment
            On 3/3/08, Sadarax <sadarax@...> wrote:
            > I do not know of anything different than the keys you have mentioned.
            >
            > But you can always map different keys to these functions. Here are some of
            > my mappings from my .vimrc file:
            >
            > " Make a new tap with CTRL+t
            > :nmap <C-t> :tabnew<cr>
            > :imap <C-t> <ESC>:tabnew<cr>
            >
            > " Go to the next tab with a key press while in navigation mode
            > :nmap <tab> :tabnext<cr>
            >
            > " Go to previous tab with Shift+h and next tab with Shift+l in navigation
            > mode
            > :nmap <S-h> gT
            > :nmap <S-l> gt
            >
            > " Move to next tab while within insert mode
            > :imap <C-E> <ESC>:tabnext<cr>a
            >
            > And those this is not related to what you want, I often use this to spawn a
            > new tab (or Explorer window).
            >
            > " Run Explorer in a new Tab
            > imap <F1> <Esc>:call RunExplorer() <CR>
            > cmap <F1> :call RunExplorer() <CR>
            > nmap <silent> <F1> :call RunExplorer() <CR>
            > function! RunExplorer()
            > if expand("%") != ""
            > tabnew
            > endif
            > Explore
            > endfunction
            >
            > I hope that helps.
            >
            > On Sun, Mar 2, 2008 at 9:32 PM, Jeenu <jeenuv@...> wrote:
            >
            > >
            > > Hi,
            > >
            > > I wonder whether there is a command which would open alternate tab,
            > > similar to CTRL-^ for alternate buffer. This would be particularly
            > > useful when working with 2 tabs most of the time. It's a bit painful
            > > to use multiple 'gt' and 'gT', unless they are placed next to each
            > > other using ':tabm'
            > >
            >

            I used to use CTRL-T for new tab, but then I realized that CTRL-T is
            "jump back from tag" by default. So, if navigating help files, you can
            jump back after following a link with CTRL-]. The same goes for if you
            use CTags with Vim. So, I'd certainly recommend NOT using that
            particular mapping.

            As for the question at hand (how to easily jump to any tab) I do the following:

            1. Set up your guitablabel (if your system supports it) or your
            tabline (if it doesn't) to display the tab number somewhere on the
            tab. See :help 'tabline' and :help 'guitablabel'
            2. Navigate to the tab in question using [N]gt, where N is the tab
            number, grabbed from the display you just set up.

            Here's my particular guitablabel setup for an example:

            " set up tab labels with tab number, buffer name, number of windows
            function! GuiTabLabel()
            let label = ''
            let bufnrlist = tabpagebuflist(v:lnum)

            " Add '+' if one of the buffers in the tab page is modified
            for bufnr in bufnrlist
            if getbufvar(bufnr, "&modified")
            let label = '+'
            break
            endif
            endfor

            " Append the tab number
            let label .= tabpagenr().': '

            " Append the buffer name
            let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
            if name == ''
            " give a name to no-name documents
            let name = '[No Name]'
            else
            " get only the file name
            let name = fnamemodify(name,":t")
            endif
            let label .= name

            " Append the number of windows in the tab page
            let wincount = tabpagewinnr(v:lnum, '$')
            return label . ' [' . wincount . ']'
            endfunction

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Benjamin Fritz
            ... Forgot the most important part: set guitablabel=%{GuiTabLabel()} --~--~---------~--~----~------------~-------~--~----~ You received this message from the
            Message 5 of 5 , Mar 3 7:51 AM
            • 0 Attachment
              On 3/3/08, Benjamin Fritz <fritzophrenic@...> wrote:
              > On 3/3/08, Sadarax <sadarax@...> wrote:
              > > I do not know of anything different than the keys you have mentioned.
              > >
              > > But you can always map different keys to these functions. Here are some of
              > > my mappings from my .vimrc file:
              > >
              > > " Make a new tap with CTRL+t
              > > :nmap <C-t> :tabnew<cr>
              > > :imap <C-t> <ESC>:tabnew<cr>
              > >
              > > " Go to the next tab with a key press while in navigation mode
              > > :nmap <tab> :tabnext<cr>
              > >
              > > " Go to previous tab with Shift+h and next tab with Shift+l in navigation
              > > mode
              > > :nmap <S-h> gT
              > > :nmap <S-l> gt
              > >
              > > " Move to next tab while within insert mode
              > > :imap <C-E> <ESC>:tabnext<cr>a
              > >
              > > And those this is not related to what you want, I often use this to spawn a
              > > new tab (or Explorer window).
              > >
              > > " Run Explorer in a new Tab
              > > imap <F1> <Esc>:call RunExplorer() <CR>
              > > cmap <F1> :call RunExplorer() <CR>
              > > nmap <silent> <F1> :call RunExplorer() <CR>
              > > function! RunExplorer()
              > > if expand("%") != ""
              > > tabnew
              > > endif
              > > Explore
              > > endfunction
              > >
              > > I hope that helps.
              > >
              > > On Sun, Mar 2, 2008 at 9:32 PM, Jeenu <jeenuv@...> wrote:
              > >
              > > >
              > > > Hi,
              > > >
              > > > I wonder whether there is a command which would open alternate tab,
              > > > similar to CTRL-^ for alternate buffer. This would be particularly
              > > > useful when working with 2 tabs most of the time. It's a bit painful
              > > > to use multiple 'gt' and 'gT', unless they are placed next to each
              > > > other using ':tabm'
              > > >
              > >
              >
              >
              > I used to use CTRL-T for new tab, but then I realized that CTRL-T is
              > "jump back from tag" by default. So, if navigating help files, you can
              > jump back after following a link with CTRL-]. The same goes for if you
              > use CTags with Vim. So, I'd certainly recommend NOT using that
              > particular mapping.
              >
              > As for the question at hand (how to easily jump to any tab) I do the following:
              >
              > 1. Set up your guitablabel (if your system supports it) or your
              > tabline (if it doesn't) to display the tab number somewhere on the
              > tab. See :help 'tabline' and :help 'guitablabel'
              > 2. Navigate to the tab in question using [N]gt, where N is the tab
              > number, grabbed from the display you just set up.
              >
              > Here's my particular guitablabel setup for an example:
              >
              > " set up tab labels with tab number, buffer name, number of windows
              > function! GuiTabLabel()
              > let label = ''
              > let bufnrlist = tabpagebuflist(v:lnum)
              >
              > " Add '+' if one of the buffers in the tab page is modified
              > for bufnr in bufnrlist
              > if getbufvar(bufnr, "&modified")
              > let label = '+'
              > break
              > endif
              > endfor
              >
              > " Append the tab number
              > let label .= tabpagenr().': '
              >
              > " Append the buffer name
              > let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
              > if name == ''
              > " give a name to no-name documents
              > let name = '[No Name]'
              > else
              > " get only the file name
              > let name = fnamemodify(name,":t")
              > endif
              > let label .= name
              >
              > " Append the number of windows in the tab page
              > let wincount = tabpagewinnr(v:lnum, '$')
              > return label . ' [' . wincount . ']'
              > endfunction
              >

              Forgot the most important part:

              set guitablabel=%{GuiTabLabel()}

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.