Ⅰ. 插件描述lean & mean status/tabline for vim that's light as air
:source % :PluginInstall
对于Vundle版本 < 0.10.2，请用上面的Bundle替换Plugin。
:source % :NeoBundleInstall
:source % :PlugInstall
cd ~/.vim/bundle git clone https://github.com/bling/vim-airline
Lean & mean status/tabline for vim that's light as air.
When the plugin is correctly loaded, Vim will draw a nice statusline at the
bottom of each window.
That line consists of several sections, each one displaying some piece of
- By default (without configuration) this line will look like this:
+-----------------------------------------------------------------------------+ |~ | |~ | |~ VIM - Vi IMproved | |~ | |~ version 8.2 | |~ by Bram Moolenaar et al. | |~ Vim is open source and freely distributable | |~ | |~ type :h :q<Enter> to exit | |~ type :help<Enter> or <F1> for on-line help | |~ type :help version8<Enter> for version info | |~ | |~ | +-----------------------------------------------------------------------------+ | A | B | C X | Y | Z | [...] | +-----------------------------------------------------------------------------+
The statusline is the colored line at the bottom, which contains the sections
(possibly in different colors):
|A||displays the mode + additional flags like crypt/spell/paste (INSERT)|
|B||VCS information (branch, hunk summary) (master)|
|C||filename + read-only flag (~/.vim/vimrc RO)|
|Y||file encoding[fileformat] (utf-8[unix])|
|Z||current position in the file|
|[...]||additional sections (warning/errors/statistics) from external plugins (e.g. YCM, syntastic, ...)|
The information in Section Z looks like this:
10% ☰ 10/100 ln : 20
10% - 10 percent down the top of the file ☰ 10 - current line 10 /100 ln - of 100 lines : 20 - current column 20
For a better look, those sections can be colored differently, depending on various conditions
(e.g. the mode or whether the current file is 'modified')
- Tiny core written with extensibility in mind (open/closed principle).
- Integrates with a variety of plugins, including: vim-bufferline,
fugitive, unite, ctrlp, minibufexpl, gundo,
- Looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols.
- Optimized for speed; it loads in under a millisecond.
- Extensive suite of themes for popular color schemes including solarized (dark and light), tomorrow (all variants), base16 (all variants), molokai, jellybeans and others.
Note these are now external to this plugin. See below for detail.
- Supports 7.2 as the minimum Vim version.
- The master branch tries to be as stable as possible, and new features are merged in only after they have gone through a full regression test.
- Unit testing suite.
If you don't like the defaults, you can replace all sections with standard
statusline syntax. Give your statusline that you've built over the years a face lift.
Themes have moved to
another repository as of this commit.
Install the themes as you would this plugin (Vundle example):
Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes'
See https://github.com/vim-airline/vim-airline-themes for more.
Sections and parts within sections can be configured to automatically hide when the window size shrinks.
Smarter tab line
Automatically displays all buffers when there's only one tab open.
This is disabled by default; add the following to your vimrc to enable the extension:
let g:airline#extensions#tabline#enabled = 1
Separators can be configured independently for the tabline, so here is how you can define "straight" tabs:
let g:airline#extensions#tabline#left_sep = ' ' let g:airline#extensions#tabline#left_alt_sep = '|'
In addition, you can also choose which path formatter airline uses. This affects how file paths are
displayed in each individual tab as well as the current buffer indicator in the upper right.
To do so, set the
formatter field with:
let g:airline#extensions#tabline#formatter = 'default'
Here is a complete list of formatters with screenshots:
vim-airline integrates with a variety of plugins out of the box. These extensions will be lazily loaded if and only if you have the other plugins installed (and of course you can turn them off).
hunks (vim-gitgutter & vim-signify)
vim-airline also supplies some supplementary stand-alone extensions. In addition to the tabline extension mentioned earlier, there is also:
statusline on top
The statusline can alternatively by drawn on top, making room for other plugins to use the statusline:
The example shows a custom statusline setting, that imitates Vims default statusline, while allowing
to call custom functions. Use
:let g:airline_statusline_ontop=1 to enable it.
Configurable and extensible
Every section is composed of parts, and you can reorder and reconfigure them at will.
Sections can contain accents, which allows for very granular control of visuals (see configuration here).
Completely transform the statusline to your liking. Build out the statusline as you see fit by extracting colors from the current colorscheme's highlight groups.
There's already powerline, why yet another statusline?
- 100% vimscript; no python needed.
What about vim-powerline?
- vim-powerline has been deprecated in favor of the newer, unifying powerline, which is under active development; the new version is written in python at the core and exposes various bindings such that it can style statuslines not only in vim, but also tmux, bash, zsh, and others.
Where did the name come from?
I wrote the initial version on an airplane, and since it's light as air it turned out to be a good name. Thanks for flying vim!
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
|Plugin Manager||Install with...|
|pack feature (native Vim 8 package feature)|
|manual||copy all of the files into your |
Integrating with powerline fonts
For the nice looking powerline symbols to appear, you will need to install a patched font. Instructions can be found in the official powerline documentation. Prepatched fonts can be found in the powerline-fonts repository.
Finally, you can add the convenience variable
let g:airline_powerline_fonts = 1 to your vimrc which will automatically populate the
g:airline_symbols dictionary with the powerline symbols.
Solutions to common problems can be found in the Wiki.
Whoa! Everything got slow all of a sudden...
vim-airline strives to make it easy to use out of the box, which means that by default it will look for all compatible plugins that you have installed and enable the relevant extension.
Many optimizations have been made such that the majority of users will not see any performance degradation, but it can still happen. For example, users who routinely open very large files may want to disable the
tagbar extension, as it can be very expensive to scan for the name of the current function.
The minivimrc project has some helper mappings to troubleshoot performance related issues.
If you don't want all the bells and whistles enabled by default, you can define a value for
g:airline_extensions. When this variable is defined, only the extensions listed will be loaded; an empty array would effectively disable all extensions (e.g.
:let g:airline_extensions = ).
Also, you can enable caching of the various syntax highlighting groups. This will try to prevent some of the more expensive
:hi calls in Vim, which seem to be expensive in the Vim core at the expense of possibly not being one hundred percent correct all the time (especially if you often change highlighting groups yourself using
:hi commands). To set this up do
:let g:airline_highlighting_cache = 1. A
:AirlineRefresh will however clear the cache.
In addition you might want to check out the dark_minimal theme, which does not change highlighting groups once they are defined. Also please check the FAQ for more information on how to diagnose and fix the problem.
A full list of screenshots for various themes can be found in the Wiki.
If you are interested in becoming a maintainer (we always welcome more maintainers), please go here.
MIT License. Copyright (c) 2013-2020 Bailey Ling & Contributors.