Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice to shorten statusline #1309

Closed
protist opened this issue Nov 2, 2016 · 9 comments
Closed

Advice to shorten statusline #1309

protist opened this issue Nov 2, 2016 · 9 comments

Comments

@protist
Copy link

protist commented Nov 2, 2016

environment

  • vim: 8.0.0055
  • vim-airline: 1:0.8.r151.g0ea4daa (latest)
  • OS: Arch Linux
  • Have you reproduced with a minimal vimrc: N/A
  • What is your airline configuration: some parts reproduced below.
    if you are using terminal:
  • terminal: terminator 0.98
  • $TERM variable: xterm-256color
  • color configuration (:set t_Co?): 256
    if you are using Neovim:
  • does it happen in Vim: N/A

actual behavior

I'm find the statusline a little cramped when I tile terminal windows horizontally, and I have long filenames and/or long (tagbar) sections. Hence, I'm attempting to shorten the statusline.

I've so far reduced the size of the mode indicator with

let g:airline_mode_map = {
    \ '__' : '-',
    \ 'n'  : 'N',
    \ 'i'  : 'I',
    \ 'R'  : 'R',
    \ 'c'  : 'C',
    \ 'v'  : 'V',
    \ 'V'  : 'V',
    \ '' : 'V',
    \ 's'  : 'S',
    \ }

I've also reduced the z section by six characters by removing some of the special characters and spacing, and reducing some leading space.

let g:airline_section_z = '%3p%% %3l/%L:%3v'

desired behavior

However, there's potentially two other regions that I could probably abbreviate.

  1. 90% of the time I'm editing a UTF-8 unix file, which makes utf-8[unix] show in the statusline. Is there a way to remove this if it's utf-8[unix], and show it if it's a different string?
  2. I have the word count shown with let g:airline#extensions#wordcount#enabled = 1. This now shows (e.g.) 1,570 words in the statusbar. Is there a way to save 4 characters by abbreviating words to w?

edit

And I just realised that my g:airline_section_z modification doesn't work so well. Nothing is displayed in the file until I move the cursor. If I remove this line, then the z section displays immediately on opening a file.

@chrisbra
Copy link
Member

chrisbra commented Dec 13, 2016

  1. you can use the variable let g:airline#extensions#wordcount#format = '%d words' to shorten the output

I just added a commit to document that variable

  1. is more interesting

@chrisbra
Copy link
Member

With #a69834 you can now set let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]' to have it skipped.

@protist
Copy link
Author

protist commented Dec 14, 2016

Thanks for that commit, that's fantastic! It works very well.

However, I couldn't change the word count format. I set the following in ~/.vimrc

let g:airline#extensions#wordcount#format = '%d w'

I then restarted vim, but it was still showing the default n words.

Also, you might have missed my edits to the original post. Essentially, I attempted to compact the z section with

let g:airline_section_z = '%3p%% %3l/%L:%3v'

However, after restarting vim, nothing is displayed on the right side of the statusbar until I move the cursor. If I remove this line in ~/.vimrc, then the z section displays immediately on opening a file.

@chrisbra
Copy link
Member

I cannot reproduce this behaviour.

@protist
Copy link
Author

protist commented Jan 3, 2017

Hmm… I thought that my differing behaviour might be from one of my 16 other vim plugins conflicting with vim-airline, so I uninstalled them all, then pared down ~/.vimrc to the following.

set laststatus=2
let g:airline#extensions#wordcount#format = '%d w'
let g:airline#extensions#wordcount#enabled = 1
let g:airline#extensions#wordcount#filetypes = ''

However, vim is still showing the default n words. I also ran :scriptnames to determine what files were being sourced.

  1: /etc/vimrc
  2: /usr/share/vim/vimfiles/archlinux.vim
  3: ~/.vimrc
  4: /usr/share/vim/vimfiles/plugin/airline-themes.vim
  5: /usr/share/vim/vimfiles/plugin/airline.vim
  6: /usr/share/vim/vimfiles/autoload/airline.vim
  7: /usr/share/vim/vimfiles/autoload/airline/init.vim
  8: /usr/share/vim/vimfiles/autoload/airline/parts.vim
  9: /usr/share/vim/vim80/plugin/getscriptPlugin.vim
 10: /usr/share/vim/vim80/plugin/gzip.vim
 11: /usr/share/vim/vim80/plugin/logiPat.vim
 12: /usr/share/vim/vim80/plugin/manpager.vim
 13: /usr/share/vim/vim80/plugin/matchparen.vim
 14: /usr/share/vim/vim80/plugin/netrwPlugin.vim
 15: /usr/share/vim/vim80/plugin/rrhelper.vim
 16: /usr/share/vim/vim80/plugin/spellfile.vim
 17: /usr/share/vim/vim80/plugin/tarPlugin.vim
 18: /usr/share/vim/vim80/plugin/tohtml.vim
 19: /usr/share/vim/vim80/plugin/vimballPlugin.vim
 20: /usr/share/vim/vim80/plugin/zipPlugin.vim
 21: /usr/share/vim/vimfiles/autoload/airline/extensions.vim
 22: /usr/share/vim/vimfiles/autoload/airline/extensions/quickfix.vim
 23: /usr/share/vim/vimfiles/autoload/airline/extensions/netrw.vim
 24: /usr/share/vim/vimfiles/autoload/airline/extensions/whitespace.vim
 25: /usr/share/vim/vimfiles/autoload/airline/extensions/po.vim
 26: /usr/share/vim/vimfiles/autoload/airline/extensions/wordcount.vim
 27: /usr/share/vim/vimfiles/autoload/airline/section.vim
 28: /usr/share/vim/vimfiles/autoload/airline/highlighter.vim
 29: /usr/share/vim/vimfiles/autoload/airline/themes/dark.vim
 30: /usr/share/vim/vimfiles/autoload/airline/themes.vim
 31: /usr/share/vim/vimfiles/autoload/airline/util.vim
 32: /usr/share/vim/vimfiles/autoload/airline/builder.vim
 33: /usr/share/vim/vimfiles/autoload/airline/extensions/default.vim
 34: /usr/share/vim/vimfiles/autoload/airline/extensions/wordcount/formatters/default.vim

I'm not sure how to troubleshoot further.

I also tested modifying the z section by adding the following to ~/.vimrc

let g:airline_section_z = '%3p%% %3l/%L:%3v'

This actually worked now. I reinstalled all my plugins and restored ~/.vimrc, and it broke again. I worked out that the presence of the following line prevents the z section from being displayed immediately.

let g:airline_skip_empty_sections = 1

(Oddly enough with my full ~/.vimc, a single keystroke will restore the z section, whereas with a pruned ~/.vimrc, it takes several seconds/keystrokes.)

chrisbra added a commit to chrisbra/vim-airline that referenced this issue Feb 24, 2017
@PezCoder
Copy link

PezCoder commented Aug 22, 2017

For hiding the utf 8 encoding along with devicon that shows up there I did this

let g:airline_section_y = ''6
let g:webdevicons_enable_airline_statusline_fileformat_symbols = 0

@protist
Copy link
Author

protist commented Aug 22, 2017

@PezCoder That's not exactly what I was after. As per the original post, I wanted to hide encoding only if it's utf-8[unix], but #a69834 already fixes this.

@matclab
Copy link

matclab commented Sep 7, 2018

@protist according to the code, to change the wordcount format, you shall use:

let g:airline#extensions#wordcount#formatter#default#fmt = '%d w'

@protist
Copy link
Author

protist commented Sep 7, 2018

@matclab Thanks for the suggestion. I'm not sure how, but that hard-coded the word count to 1 w, even though there are thousands of words in my document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants