Bart van Kuik wrote:
Hi
Can anyone tell me whether I can customize the tab bar in vim 7.0 (vim,
not gvim). Colours, etc.
Thanks
Bart
Sure you can. The colours are defined by the highlight groups TabLine,
TabLineSel and TabLineFill; you may also define the contents of the tabs
by means of the 'tabline' option.
see
:help hl-TabLine
:help hl-TabLineFill
:help hl-TabLineSel
:help 'tabline'
:help setting-tabline
Here are code snippets showing how I do it:
----- 8< ----- ~/.vimrc
if exists("+guioptions")
set go-=a go-=e go+=t
endif
if exists("+showtabline")
function MyTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let s .= i . ':'
let s .= winnr . '/' . tabpagewinnr(i,'$')
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let file = bufname(buflist[winnr - 1])
let file = fnamemodify(file, ':p:t')
if file == ''
let file = '[No Name]'
endif
let s .= file
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=2
set tabline=%!MyTabLine()
map <F10> :tabnext<CR>
map! <F10> <C-O>:tabnext<CR>
map <S-F10> :tabprev<CR>
map! <S-F10> <C-O>:tabprev<CR>
endif
----- >8 -----
----- 8< ----- ~/.vim/colors/almost-default.vim
hi TabLine gui=NONE guibg=#DDDDDD guifg=black
hi TabLineFill gui=NONE guibg=#AAAAAA guifg=red
hi User1 ctermfg=magenta guibg=white guifg=magenta
hi User2 ctermfg=darkmagenta guibg=#DDDDDD guifg=magenta
----- >8 -----
Notes:
- The above are _parts_ of the concerned scripts.
- Highlight groups not defined in the colorscheme use their default
colours; those with only gui= guibg= guifg= use their defaults when in
Console mode.
- Clearing the e flag in 'guioptions' forces gvim to use a non-GUI-like
tabline.
Best regards,
Tony.