Annoying vim tab line labels

This is not an indented question.

Vim's behavior to navigate the window really annoys me. Suppose this configuration of the current window is open and the file wp-config-sample.php

is current:

enter image description here

Since all other files are in a different directory, if I focus any of them on execution <ESC>gt

, they all change their content, and the tabs change as well:

enter image description here

This is a simple example, but the problem really occurs when there are many tabs open and I can't just figure out where I am because the focused tab has changed its position significantly from its original position.

What I expect as good behavior is the same system in Firefox, where the focused and unfocused tab never changes its position and the focused tab is only slightly underlined.

Is there a way to stop it?

+3


source to share


3 answers


tappi, on #vim in Freenode, explained that it was included autochdir

. To quickly fix this:

:set noautochdir

      



And coot pointed me to a good vim wiki link with a nice snippet that works great in .vimrc

to save autochdir

as well as keeping the regular tab title when navigating through windows.

Now my tabs are beautiful!

+3


source


Yes, you can only display filenames in Vim. See :h tabline

and :h filename-modifiers

.



+1


source


Yes, the default tab labels make tabs really annoying when you enable autochdir. Basically, they show you the full path (shorthand) if yours :pwd

is something other than the file location, and just the filename if yours is the :pwd

same as the file. When you turn it on autochdir

, yours :pwd

changes every time the buffer is loaded, including when switching tabs. I like it autochdir

, because :ls

any file operations are automatically associated with the active cwd buffer. I always know this location because I have the full path in my status bar.

I have gui tabs to show me a few different things ... Tab number, changed indicator if there are multiple windows in the tab (show count) and always only show buffer filename (using one in active window if there is more than one window ).

" GUI Tab label full path
function! GuiTabLabeler()
  let tabno = tabpagenr()
  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 number of windows in the tab page if more than one
  let wincount = tabpagewinnr(v:lnum, '$')
  if wincount > 1
    let label .= ' [' . wincount . ']'
  endif

  " Append the buffer name
  return tabno . " " . 
         \ fnamemodify(bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]), ":t")
         \ . label
endfunction

set guitablabel=%!GuiTabLabeler()

      

The tab numbers on the tabs are nice, especially if you're doing something like mapping your alt numbers to them:

" Tab navigation in with alt-#
noremap <A-1> :tabnext 1<CR>
noremap <A-2> :tabnext 2<CR>
noremap <A-3> :tabnext 3<CR>
noremap <A-4> :tabnext 4<CR>
noremap <A-5> :tabnext 5<CR>
noremap <A-6> :tabnext 6<CR>
noremap <A-7> :tabnext 7<CR>
noremap <A-8> :tabnext 8<CR>
noremap <A-9> :tabnext 9<CR>
noremap <A-0> :tabnext 0<CR>

      

This way my gui tabs stay pretty narrow and clean. I prefer to have the full path filename in my status bar (among other things):

" Statusline 
set laststatus=2
let &statusline='%F  %r%m  [%{&fileformat}]%y[%{strlen(&fenc)?&fenc:&enc}]'
           \ . '%= --%3p%% --   l:%3l, c:%3c (%03b 0x%02B)'

      

+1


source







All Articles