4

I am okay with rest of the section z but I want to remove ㏑ : 1 from the default section z configuration because I think it's not useful for me and takes up the space unnecessarily. Is there a way of doing this?

Hashir Sarwar
  • 213
  • 3
  • 9

1 Answers1

4

You can inspect the default value of g:airline_section_z by issuing :echo g:airline_section_z. Note, this includes already the bold accents.

In airline, the default is set to:

  if airline#util#winwidth() > 79
    let g:airline_section_z = airline#section#create(['windowswap', 'obsession', '%3p%%'.spc, 'linenr', 'maxlinenr', spc.':%3v'])
  else
    let g:airline_section_z = airline#section#create(['%3p%%'.spc, 'linenr',  ':%3v'])
  endif

(where spc means Space, and it depends on the terminal width, which parts are included).

So you can customize this by setting the g:airline_section_z variable. Unfortunately, since by the time the vimrc file is read, vim-airline has not been read yet, so you need to postpone configuring the variable until vim-airline has been read. For that purpose, vim-airline exposes the AirlineAfterInit autocommand event.

Putting it all together, you would want to configure your section like this in your .vimrc:

au User AirlineAfterInit  :let g:airline_section_z = airline#section#create(['windowswap', 'obsession', '%3p%%', 'maxlinenr', ' :%3v'])

or for a very simple one:

au User AirlineAfterInit  :let g:airline_section_z = airline#section#create(['%3p%% %L:%3v'])

For the meanings of the %-expandos have a look at :h 'statusline'

Christian Brabandt
  • 25,820
  • 1
  • 52
  • 77
  • This does not seem up-do-date anymore, because I get E121: Undefined variable: spc E116: Invalid arguments for function airline#section#create E15: Invalid expression: airline#section#create(['windowswap', 'obsession', '%3p%%'.spc, 'linenr', 'maxlinenr', spc.':%3v']) when I copy what is claimed to be default in this answer. Furthermore, if I use the echo command, in my case g:airline_section_z is set to: %p%% %#__accent_bold#%{g:airline_symbols.linenr}%l%#__restore__#%#__accent_bold#/%L%{g:airline_symbols.maxlinenr}%#__restore__#:%v – Philipp Ludwig Mar 25 '21 at 06:54
  • @PhilippLudwig the variable spc is not defined. You need to define it before using it. – Christian Brabandt Mar 26 '21 at 07:31