Skip to content

linhns/vim-autocenter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-autocenter

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.

Requirements

Vim 9.0 or above (support for vim9script is required)

Installation

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()

Usage

After installation, this plugin is enabled by default.

Commands

Command Description
AutocenterEnable Enable autocenter
AutocenterDisable Disable autocenter

Configuration

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,
    \ }

Mappings

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>

Contributing

Feel free to fork this repo and experiment with any changes to suit your workflow.

Issues are more than welcome. Please submit them here.

Credits

  • This post on Vi and Vim StackExchange

  • girishji for his instructions on how to write a Vim9 plugin

About

Minimal Vim plugin to automatically center cursor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published