Created
September 10, 2010 13:08
-
-
Save chexov/573590 to your computer and use it in GitHub Desktop.
vim with tabs config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" http://ja.pastebin.ca/raw/1243579 | |
" }}} | |
" MyTabLine {{{ | |
" This is an attempt to emulate the default Vim-7 tabs as closely as possible but with numbered tabs. | |
" TODO: set truncation when tabs don't fit on line, see :h columns | |
if exists("+showtabline") | |
function! MyTabLine() | |
let s = '' | |
for i in range(tabpagenr('$')) | |
" set up some oft-used variables | |
""let tab = i + 1 " range() starts at 0 | |
let tab = i + 0 " range() starts at 0 | |
let winnr = tabpagewinnr(tab) " gets current window of current tab | |
let buflist = tabpagebuflist(tab) " list of buffers associated with the windows in the current tab | |
let bufnr = buflist[winnr - 1] " current buffer number | |
let bufname = bufname(bufnr) " gets the name of the current buffer in the current window of the current tab | |
let s .= '%' . tab . 'T' " start a tab | |
let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#') " if this tab is the current tab...set the right highlighting | |
let s .= ' #' . tab " current tab number | |
let n = tabpagewinnr(tab,'$') " get the number of windows in the current tab | |
if n > 1 | |
let s .= ':' . n " if there's more than one, add a colon and display the count | |
endif | |
let bufmodified = getbufvar(bufnr, "&mod") | |
if bufmodified | |
let s .= ' +' | |
endif | |
if bufname != '' | |
let s .= ' ' . pathshorten(bufname) . ' ' " outputs the one-letter-path shorthand & filename | |
else | |
let s .= ' [No Name] ' | |
endif | |
endfor | |
let s .= '%#TabLineFill#' " blank highlighting between the tabs and the righthand close 'X' | |
let s .= '%T' " resets tab page number? | |
let s .= '%=' " seperate left-aligned from right-aligned | |
let s .= '%#TabLine#' " set highlight for the 'X' below | |
let s .= '%999XX' " places an 'X' at the far-right | |
return s | |
endfunction | |
set tabline=%!MyTabLine() | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment