Provides indent functions for buffer. Simple, fast, robust, with no side effects.
Install using your favorite package manager, or manually.
For Pathogen:
git clone https://github.com/iibe/vim-autoindent ~/.vim/bundle/vim-autoindent
Remember to run
:Helptags
to generate help tags.
For neobundle.vim:
NeoBundle 'iibe/vim-autoindent'
For Vundle.vim:
Plugin 'iibe/vim-autoindent'
For vim-plug:
Plug 'iibe/vim-autoindent'
For vim-addon-manager:
call vam#ActivateAddons([ 'vim-autoindent' ])
For dein.vim:
call dein#add('iibe/vim-autoindent')
For minpac:
call minpac#add('iibe/vim-autoindent')
For Neovim:
git clone https://github.com/iibe/vim-autoindent.git ~/.config/nvim/plugged/vim-autoindent
For Vim:
git clone https://github.com/iibe/vim-autoindent.git ~/.vim/bundle/vim-autoindent
For Vim 8 (pack):
git clone https://github.com/iibe/vim-autoindent ~/.vim/pack/dist/start/vim-autoindent
Remember to run
:helptags ~/.vim/pack/dist/start/vim-autoindent/doc
to generate help tags.
Map keys or use format-on-save feature.
nnoremap <silent> <leader>ib :VaiBuffer<CR>
nnoremap <silent> <leader>ibi :VaiBufferIndentation<CR>
nnoremap <silent> <leader>ibw :VaiBufferWhitespaces<CR>
nnoremap <silent> <leader>if :VaiFolder<CR>
nnoremap <silent> <leader>ifi :VaiFolderIndentation<CR>
nnoremap <silent> <leader>ifw :VaiFolderWhitespaces<CR>
This is a potentially dangerous
autocmd
to have as it will always strip trailing whitespace and fix indentation from every file a user saves. Sometimes, trailing whitespace and native indentation is desired, or even essential in a file so be careful when implementing thisautocmd
. Use this features at your own risk.
For current file:
autocmd BufWritePre * call autoindent#Buffer()
For whole project (without .gitignore
files):
autocmd BufWritePre * call autoindent#Folder()
- If you get an error during installation, try to visit official repository for your package manager (since it's probably some typo or guide it outdated by itself).
- If you have any suggestions for how the plugin works, feel free to do pull request.
- If you think vim-autoindent is useful, consider giving it a star.
- If you have a bug or an idea, feel free to open an issue.