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

87958Re: Alternate Tab

Expand Messages
  • Benjamin Fritz
    Mar 3, 2008
    • 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 = '+'

      " 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]'
      " get only the file name
      let name = fnamemodify(name,":t")
      let label .= name

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

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 5 messages in this topic