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

Re: Removing the path from the tabline

Expand Messages
  • 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 1 of 10 , Mar 31, 2006
    • 0 Attachment
      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
      >
      >
    • Bram Moolenaar
      ... And what if you have the same file name in two or more different directories? E.g., Makefile . -- ARTHUR: CHARGE! [The mighty ARMY charges. Thundering
      Message 2 of 10 , Mar 31, 2006
      • 0 Attachment
        Matt 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.

        And what if you have the same file name in two or more different
        directories? E.g., "Makefile".

        --
        ARTHUR: CHARGE!
        [The mighty ARMY charges. Thundering noise of feet. Clatter of coconuts.
        Shouts etc. Suddenly there is a wail of a siren and a couple of police
        cars roar round in front of the charging ARMY and the POLICE leap out and
        stop them. TWO POLICEMAN and the HISTORIAN'S WIFE. Black Marias skid up
        behind them.]
        HISTORIAN'S WIFE: They're the ones, I'm sure.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://www.ICCF.nl ///
      • Nicolas Weber
        ... Another problem is that the tab size changes if you :lcd in one tab and not in the others; when you click the :lcd d tab all paths in the tabs change and
        Message 3 of 10 , Mar 31, 2006
        • 0 Attachment
          >> 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.
          >>
          >
          > And what if you have the same file name in two or more different
          > directories? E.g., "Makefile".
          >

          Another problem is that the tab size changes if you :lcd in one tab and
          not in the others; when you click the :lcd'd tab all paths in the tabs
          change and so the position of most tabs changes.

          [I'd prefer it if all tabs in the tabline are the same size (which
          becomes smaller if there are so many tabs in the tabline that it would
          overflow); the filenames in the tabs could be right-aligned so that the
          less interesting left part is clipped first. But this has probably
          already been discussed ;-) ]

          Nico
        • Steve Hall
          From: Bram Moolenaar, Mar 31, 2006 2:43 PM ... That s what the window title or buffer menu are for. Tabs can t relay all information about the file, the name
          Message 4 of 10 , Mar 31, 2006
          • 0 Attachment
            From: Bram Moolenaar, Mar 31, 2006 2:43 PM
            > Matt 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.
            >
            > And what if you have the same file name in two or more different
            > directories? E.g., "Makefile".

            That's what the window title or buffer menu are for. Tabs can't relay
            all information about the file, the name is the simplest and most
            easily understood abstraction.


            --
            Steve Hall [ digitect mindspring com ]
          • James Vega
            ... One thing I think is handy and have seen a few programs do is to reduce all parts of the path except for the final part to a single letter. It reduces how
            Message 5 of 10 , Mar 31, 2006
            • 0 Attachment
              On Fri, Mar 31, 2006 at 09:43:08PM +0200, Bram Moolenaar wrote:
              >
              > Matt 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.
              >
              > And what if you have the same file name in two or more different
              > directories? E.g., "Makefile".

              One thing I think is handy and have seen a few programs do is to reduce
              all parts of the path except for the final part to a single letter. It
              reduces how much space is taken up, but still gives some context as to
              where the file is located.

              ~/Code/Foo/Bar/baz.c => ~/C/F/B/baz.c

              James
              --
              GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
            • mzyzik@gmail.com
              ... Then change the tabline. You can already see the full path in the statusline and the window title. Why have it in a third place? Maybe if you have 12
              Message 6 of 10 , Mar 31, 2006
              • 0 Attachment
                > Matt 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.
                >
                > And what if you have the same file name in two or more different
                > directories? E.g., "Makefile".

                Then change the tabline. You can already see the full path in the
                statusline and the window title. Why have it in a third place?

                Maybe if you have 12 Makefiles open it's a problem, but you shouldn't be
                using tab pages, but rather some plugin like MiniBufExplr.

                --Matt
              • Halim, Salman
                Tony Mechelynck had provided a non-GUI tabline function, which I have modified to the following: function! MyGuiTabLine() let s = let i = tabpagenr() let s
                Message 7 of 10 , Mar 31, 2006
                • 0 Attachment
                  Tony Mechelynck had provided a non-GUI tabline function, which I have
                  modified to the following:

                  function! MyGuiTabLine()
                  let s = ''
                  let i = tabpagenr()
                  let s .= '%' . i . 'T'
                  " a(b/c), where
                  " a = tab number
                  " b = current window number in tab
                  " c = total number of windows in tab
                  let s .= ' ' . i . '(' . tabpagewinnr(i ) . '/' .
                  \ tabpagewinnr(i,'$') . ') '
                  " filename for current window in tab, without path
                  let b = fnamemodify( bufname(tabpagebuflist(i )[tabpagewinnr(i ) -
                  1]), ':t')
                  " if empty, display [No Name]
                  if b == ''
                  let b = '[No Name]'
                  else
                  let b = substitute( fnamemodify( bufname(tabpagebuflist(i
                  )[tabpagewinnr(i ) - 1]), ':p'), '\([^/\\:]\)[^/\\:]*\([/\\]\)', '\1\2',
                  'g' )
                  endif

                  let bufnrlist = tabpagebuflist(v:lnum)
                  for bufnr in bufnrlist
                  if getbufvar(bufnr, "&modified")
                  let s .= '+'
                  break
                  endif
                  endfor
                  let s .= b

                  return s
                  endfunction
                  set guitablabel=%!MyGuiTabLine()

                  This displays something like:

                  3(2/4) c:/v/V/p/TabLine.vim

                  Where 3 is the number of the tab (it's the 3rd tab) and 2/4 means that
                  tab 3 has 4 windows, and that the current one is number 2.

                  If you don't like the truncated path and want just the filename, simply
                  comment out:

                  else
                  let b = substitute( fnamemodify( bufname(tabpagebuflist(i
                  )[tabpagewinnr(i ) - 1]), ':p'), '\([^/\\:]\)[^/\\:]*\([/\\]\)', '\1\2',
                  'g' )

                  If you want the full path, leave the 'else' in there and change the
                  second line to:

                  let b = fnamemodify( bufname(tabpagebuflist(i )[tabpagewinnr(i ) -
                  1]), ':p')

                  Be warned, though, as it can be get long.

                  Hope this helps,

                  Salman.

                  > -----Original Message-----
                  > From: James Vega [mailto:jamessan@...]
                  > Sent: Friday, March 31, 2006 3:23 PM
                  > To: vim-dev@...
                  > Subject: Re: Removing the path from the tabline
                  >
                  > On Fri, Mar 31, 2006 at 09:43:08PM +0200, Bram Moolenaar wrote:
                  > >
                  > > Matt 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.
                  > >
                  > > And what if you have the same file name in two or more different
                  > > directories? E.g., "Makefile".
                  >
                  > One thing I think is handy and have seen a few programs do is
                  > to reduce all parts of the path except for the final part to
                  > a single letter. It reduces how much space is taken up, but
                  > still gives some context as to where the file is located.
                  >
                  > ~/Code/Foo/Bar/baz.c => ~/C/F/B/baz.c
                  >
                  > James
                  > --
                  > GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
                  >
                • 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 8 of 10 , Mar 31, 2006
                  • 0 Attachment
                    --- 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 9 of 10 , Mar 31, 2006
                    • 0 Attachment
                      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
                    • Stefano Zacchiroli
                      ... What about reducing the path to the least part that make possible to disambiguate file names? As long as all are not ambiguous you just use the basename.
                      Message 10 of 10 , Apr 2, 2006
                      • 0 Attachment
                        On Fri, Mar 31, 2006 at 09:43:08PM +0200, Bram Moolenaar wrote:
                        > And what if you have the same file name in two or more different
                        > directories? E.g., "Makefile".

                        What about reducing the path to the least part that make possible to
                        disambiguate file names?

                        As long as all are not ambiguous you just use the basename. In the
                        example above something lile ".../foo/Makefile" vs ".../bar/Makefile" (3
                        dots or something different that helps understanding that the full path
                        has been truncated).

                        Cheers.

                        --
                        Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
                        zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
                        If there's any real truth it's that the entire multidimensional infinity
                        of the Universe is almost certainly being run by a bunch of maniacs. -!-
                      Your message has been successfully submitted and would be delivered to recipients shortly.