This plugin is for those often have to exit to Normal mode
and press zz
.
It is meant to be minimal while trying to be as smart as possible to detect whether the user wants to center automatically or not.
Works out of the box and remains configurable.
Vim 9.0 or above (support for vim9script is required)
Please follow your package manager instructions on how to install plugins, or use Vim in-built package system.
I recommend vim-plug:
call plug#begin()
Plug 'linhns/vim-autocenter'
call plug#end()
After installation, this plugin is enabled by default.
Command | Description |
---|---|
AutocenterEnable |
Enable autocenter |
AutocenterDisable |
Disable autocenter |
Option | Description | Default |
---|---|---|
activation_ratio |
The ratio of current window line / window height where centering starts. | 0.5 |
It is recommended to keep the ratio at 0.5 as it gives a typewritting-like experience.
Example
let g:autocenter_options =
\ {
\ 'activation_ratio': 0.5,
\ }
This plugin expose no mapping at all as I believe users are best suited to define their own.
Example
nnoremap <leader>e :AutocenterEnable<cr>
nnoremap <leader>d :AutocenterDisable<cr>
Feel free to fork this repo and experiment with any changes to suit your workflow.
Issues are more than welcome. Please submit them here.