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

Removing the path from the tabline

Expand Messages
  • Brent Rice
    Hello, Having spent some time staring at the documentation for the tabline, which I would say is well summarized by the documentation s statement of This is
    Message 1 of 5 , Mar 30, 2006
      Hello,
      Having spent some time staring at the documentation for the tabline,
      which I would say is well summarized by the documentation's statement
      of "This is not easy," I have decided to pose my problem here.
      I would simply like to change my tabline to only contain the file
      names (no paths). In addition, I would like to contain the
      information for each tab in brackets, in a similar fashion to the
      buffer list in the miniBufExplorer.

      Example:

      [1:file_1.txt] [2:file_2_with_different_path.txt]

      If anybody could help with this, I would definitely appreciate it.

      Thanks!

      Brent
    • mzyzik@gmail.com
      I think by default it should display only the filename, without the path. It s much more logical that way. Paths are usually huge, and it changes the width of
      Message 2 of 5 , Mar 31, 2006
        I think by default it should display only the filename, without the
        path. It's much more logical that way. Paths are usually huge, and it
        changes the width of the tabs so much when switching to buffers with no
        paths or names. It becomes impractical.

        --Matt

        On Thu, Mar 30, 2006 at 12:15:59PM -0700, Brent Rice wrote:
        > Hello,
        > Having spent some time staring at the documentation for the tabline,
        > which I would say is well summarized by the documentation's statement
        > of "This is not easy," I have decided to pose my problem here.
        > I would simply like to change my tabline to only contain the file
        > names (no paths). In addition, I would like to contain the
        > information for each tab in brackets, in a similar fashion to the
        > buffer list in the miniBufExplorer.
        >
        > Example:
        >
        > [1:file_1.txt] [2:file_2_with_different_path.txt]
        >
        > If anybody could help with this, I would definitely appreciate it.
        >
        > Thanks!
        >
        > Brent
        >
        >
      • Eric Arnold
        ... Here is what I have so far. I still don t have the length calculation perfect for all conditions, but it does the job. if v:version = 700 else finish
        Message 3 of 5 , Mar 31, 2006
          --- mzyzik@... wrote:

          > I think by default it should display only the filename, without the
          > path. It's much more logical that way. Paths are usually huge, and it
          > changes the width of the tabs so much when switching to buffers with no
          > paths or names. It becomes impractical.
          >
          > --Matt
          >
          > On Thu, Mar 30, 2006 at 12:15:59PM -0700, Brent Rice wrote:
          > > Hello,
          > > Having spent some time staring at the documentation for the tabline,
          > > which I would say is well summarized by the documentation's statement
          > > of "This is not easy," I have decided to pose my problem here.
          > > I would simply like to change my tabline to only contain the file
          > > names (no paths). In addition, I would like to contain the
          > > information for each tab in brackets, in a similar fashion to the
          > > buffer list in the miniBufExplorer.
          > >
          > > Example:
          > >
          > > [1:file_1.txt] [2:file_2_with_different_path.txt]
          > >
          > > If anybody could help with this, I would definitely appreciate it.
          > >
          > > Thanks!
          > >
          > > Brent
          > >
          > >
          >


          Here is what I have so far. I still don't have the length calculation perfect
          for all conditions, but it does the job.



          if v:version >= 700
          else
          finish
          endif


          function! MyTabLine()
          let s = ''
          for i in range(tabpagenr('$'))
          " select the highlighting
          if i + 1 == tabpagenr()
          let s .= '%#TabLineSel#'
          else
          let s .= '%#TabLine#'
          endif

          " set the tab page number (for mouse clicks)
          let s .= '%' . (i + 1) . 'T'

          " the label is made by MyTabLabel()
          let s .= ' %{MyTabLabel(' . (i + 1) . ')} |'
          endfor

          " after the last tab fill with TabLineFill and reset tab page nr
          let s .= '%#TabLineFill#%T'

          " right-align the label to close the current tab page
          if tabpagenr('$') > 1
          let s .= '%=%#TabLine#%999X X'
          endif

          "echomsg 's:' . s
          return s
          endfunction

          function! MyTabLabel(n)
          let buflist = tabpagebuflist(a:n)
          let winnr = tabpagewinnr(a:n)
          let numtabs = tabpagenr('$')
          " account for space padding between tabs, and the "close" button
          let maxlen = ( &columns - ( numtabs * 2 ) - 4 ) / numtabs
          let tablabel = bufname(buflist[winnr - 1])
          while strlen( tablabel ) < 4
          let tablabel = tablabel . " "
          endwhile
          let tablabel = fnamemodify( tablabel, ':t' )
          let tablabel = strpart( tablabel, 0, maxlen )
          return tablabel
          endfunction

          set tabline=%!MyTabLine()

          set showtabline=1 " 2=always
          autocmd GUIEnter * hi! TabLineFill term=underline cterm=underline gui=underline
          autocmd GUIEnter * hi! TabLineSel term=bold,reverse,underline
          \ ctermfg=11 ctermbg=12 guifg=#ffff00 guibg=#0000ff gui=underline
        • Brent Rice
          ... Thanks! That s great! It appears to work pretty well...at least so far. Brent
          Message 4 of 5 , Mar 31, 2006
            On Mar 31, 2006, at 2:33 PM, Eric Arnold wrote:
            >
            >
            > Here is what I have so far. I still don't have the length
            > calculation perfect
            > for all conditions, but it does the job.
            >

            Thanks! That's great! It appears to work pretty well...at least so
            far.

            Brent
          • Eric Arnold
            I just uploaded a more complete version of the script to vim.sourceforge.net
            Message 5 of 5 , Mar 31, 2006
              I just uploaded a more complete version of the script to vim.sourceforge.net



              --- Brent Rice <riceran@...> wrote:

              > On Mar 31, 2006, at 2:33 PM, Eric Arnold wrote:
              > >
              > >
              > > Here is what I have so far. I still don't have the length
              > > calculation perfect
              > > for all conditions, but it does the job.
              > >
              >
              > Thanks! That's great! It appears to work pretty well...at least so
              > far.
              >
              > Brent
              >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.