From 00a9c7e661b5dcb69748e9050bde259303d646d6 Mon Sep 17 00:00:00 2001 From: Justine Smithies Date: Tue, 25 Nov 2025 18:29:42 +0000 Subject: Added a BufferLine with Tan numbers on the right --- .vimrc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.vimrc b/.vimrc index 7d4127d..72bbdb7 100644 --- a/.vimrc +++ b/.vimrc @@ -184,3 +184,45 @@ augroup vimrc " restore statusline highlights on colorscheme update au Colorscheme * call StatusLineHighlights() augroup END + +" Setup BufferLine with Tabs +set showtabline=2 + +function! SpawnBufferLine() + let s = '' + + " Get the list of buffers. Use bufexists() to include hidden buffers + let bufferNums = filter(range(1, bufnr('$')), 'buflisted(v:val)') + " Making a buffer list on the left side + for i in bufferNums + " Highlight with yellow if it's the current buffer + let s .= (i == bufnr()) ? ('%#TabLineSel#') : ('%#TabLine#') + let s .= i . ' ' " Append the buffer number + if bufname(i) == '' + let s .= '[No Name]' " Give a name to a new buffer + endif + if getbufvar(i, "&modifiable") + let s .= fnamemodify(bufname(i), ':t') " Append the file name + " let s .= pathshorten(bufname(i)) " Use this if you want a trimmed path + " If the buffer is modified, add + and separator. Else, add separator + let s .= (getbufvar(i, "&modified")) ? (' [+] | ') : (' | ') + else + let s .= fnamemodify(bufname(i), ':t') . ' [RO] | ' " Add read only flag + endif + endfor + let s .= '%#TabLineFill#%T' " Reset highlight + + let s .= '%=' " Spacer + + " Making a tab list on the right side + for i in range(1, tabpagenr('$')) " Loop through the number of tabs + " Highlight with yellow if it's the current tab + let s .= (i == tabpagenr()) ? ('%#TabLineSel#') : ('%#TabLine#') + let s .= '%' . i . 'T ' " set the tab page number + let s .= i . '' " set page number string + endfor + let s .= '%#TabLineFill#%T' " Reset highlight + return s +endfunction + +set tabline=%!SpawnBufferLine() " Assign the tabline -- cgit v1.2.3