Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4596302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:05:44+00:00 2026-05-21T23:05:44+00:00

In Vim, the text that forms the row of tabs at the top of

  • 0

In Vim, the text that forms the row of tabs at the top of the screen (when using tabs) is configured with the tabline option.

I’d like to make a few minor adjustments to the default tab pages line, such as replacing the number of windows in the tab with the index of the tab. Unfortunately, the default version of this (which is active when tabline is unset) is complicated and undocumented. There’s nothing for me to tweak.

Is there a piece of Vim script that provides the default implementation which I could adjust to my needs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:05:45+00:00Added an answer on May 21, 2026 at 11:05 pm

    I use a custom function to reset the tab number and viewport numbers, from here (see Tonymec’s comment). You can play with it to change how you display the tabs.

    Here’s what I have in my .vimrc. It’s only a slightly modified version, that changes how the tab# and viewport# are displayed.

    " Rename tabs to show tab# and # of viewports
    
    if exists("+showtabline")
        function! MyTabLine()
            let s = ''
            let wn = ''
            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 wn = tabpagewinnr(i,'$')
    
                let s .= (i== t ? '%#TabNumSel#' : '%#TabNum#')
                let s .= i
                if tabpagewinnr(i,'$') > 1
                    let s .= '.'
                    let s .= (i== t ? '%#TabWinNumSel#' : '%#TabWinNum#')
                    let s .= (tabpagewinnr(i,'$') > 1 ? wn : '')
                end
    
                let s .= ' %*'
                let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
                let bufnr = buflist[winnr - 1]
                let file = bufname(bufnr)
                let buftype = getbufvar(bufnr, 'buftype')
                if buftype == 'nofile'
                    if file =~ '\/.'
                        let file = substitute(file, '.*\/\ze.', '', '')
                    endif
                else
                    let file = fnamemodify(file, ':p:t')
                endif
                if file == ''
                    let file = '[No Name]'
                endif
                let s .= file
                let s .= (i == t ?  '%m' : '')
                let i = i + 1
            endwhile
            let s .= '%T%#TabLineFill#%='
            return s
        endfunction
        set stal=2
        set tabline=%!MyTabLine()
    endif
    

    And here are the colors defined in my function:

    set tabpagemax=15
    hi TabLineSel term=bold cterm=bold ctermfg=16 ctermbg=229
    hi TabWinNumSel term=bold cterm=bold ctermfg=90 ctermbg=229
    hi TabNumSel term=bold cterm=bold ctermfg=16 ctermbg=229
    
    hi TabLine term=underline ctermfg=16 ctermbg=145
    hi TabWinNum term=bold cterm=bold ctermfg=90 ctermbg=145
    hi TabNum term=bold cterm=bold ctermfg=16 ctermbg=145
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Vim to write text that isn't code, just free form writing. To
Considering that I'll be using Vim as my text editor of choice, what tools
Am using vim and have a large text file that contains some html thrown
Is there a way of formatting text in Vim that respects underlined headings? In
Possible Duplicate: When navigating through word-wrapped text in VIM, how to make the selector
I want a way to pass some literal text to Vim. I've seen that
I have lots of directories with text files written using (g)vim, and I have
I like that vim 7.0 supports spell checking via :set spell, and I like
Summary: I'd like to view my text in vim with a small bit of
I'm trying to generate a bunch of text in vim (command mode) using for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.