Add bufferlocal variants for all options.

This commit is contained in:
Chiel ten Brinke 2016-03-30 10:01:56 +02:00
parent 5b22a44982
commit 81f5e989c2
2 changed files with 9 additions and 4 deletions

View File

@ -80,6 +80,8 @@ let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0
```
To disable or re-enable these option for specific buffers, use the buffer local variants:
`b:autoformat_autoindent`, `b:autoformat_retab` and `b:autoformat_remove_trailing_spaces`.
You can manually autoindent, retab or remove trailing whitespace with the following respective
commands.
@ -95,6 +97,7 @@ tries all formatters in this list of applicable formatters, until one succeeds.
You can set this list manually in your vimrc (see section *How can I change the behaviour of formatters, or add one myself?*,
or change the formatter with the highest priority by the commands `:NextFormatter` and `:PreviousFormatter`.
To print the currently selected formatter use `:CurrentFormatter`.
These latter commands are mostly useful for debugging purposes.
If you have a composite filetype with dots (like `django.python` or `php.wordpress`),
vim-autoformat first tries to detect and use formatters for the exact original filetype, and
then tries the same for all supertypes occuring from left to right in the original filetype

View File

@ -138,26 +138,28 @@ function! s:Fallback()
" Detect verbosity
let verbose = &verbose || g:autoformat_verbosemode == 1
if g:autoformat_remove_trailing_spaces == 1
if exists('b:autoformat_remove_trailing_spaces') ? b:autoformat_remove_trailing_spaces == 1 : g:autoformat_remove_trailing_spaces == 1
if verbose
echomsg "Removing trailing whitespace..."
endif
call s:RemoveTrailingSpaces()
endif
if g:autoformat_retab == 1
if exists('b:autoformat_retab') ? b:autoformat_retab == 1 : g:autoformat_retab == 1
if verbose
echomsg "Retabbing..."
endif
retab
endif
if g:autoformat_autoindent == 1
if exists('b:autoformat_autoindent') ? b:autoformat_autoindent == 1 : g:autoformat_autoindent == 1
if verbose
echomsg "Autoindenting..."
endif
" Autoindent code
exe "normal gg=G"
endif
return 0
endfunction