From ab7778b74b5b5054fe1e11f5bf9a7ad5b4044d9a Mon Sep 17 00:00:00 2001 From: Martin Vuille Date: Thu, 8 Sep 2016 13:29:14 -0400 Subject: [PATCH] Document b:formatters_ and b:formatdef_ in README --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9927a68..bfd81c2 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ 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 +then tries the same for all supertypes occurring from left to right in the original filetype separated by dots (`.`). ## Default formatprograms @@ -118,7 +118,7 @@ Here is a list of formatprograms that are supported by default, and thus will be Clang-format is a product of LLVM source builds. If you `brew install llvm`, clang-format can be found in /usr/local/Cellar/llvm/bin/. Vim-autoformat checks whether there exists a `.clang-format` or a `_clang-format` file up in - the current directory's ancestry. Based on that it eithers uses that file or tries to match + the current directory's ancestry. Based on that it either uses that file or tries to match vim options as much as possible. Details: http://clang.llvm.org/docs/ClangFormat.html. @@ -224,7 +224,7 @@ If you need a formatter that is not among the defaults, or if you are not satisf #### Basic definitions The formatprograms that available for a certain `` are defined in `g:formatters_`. -This is a list containing string indentifiers, which point to corresponding formatter definitions. +This is a list containing string identifiers, which point to corresponding formatter definitions. The formatter definitions themselves are defined in `g:formatdef_` as a string expression. Defining any of these variable manually in your .vimrc, will override the default value, if existing. @@ -262,6 +262,16 @@ If you have a composite filetype with dots (like `django.python` or `php.wordpre vim-autoformat internally replaces the dots with underscores so you can specify formatters through `g:formatters_django_python` and so on. +To override these options for a local buffer, use the buffer local variants: +`b:formatters_` and `b:formatdef_`. This can be useful, for example, when +working with different projects with conflicting formatting rules, with each project having settings +in its own vimrc or exrc file: + +```vim +let b:formatdef_custom_c='"astyle --mode=c --suffix=none --options=/home/user/special_project/astylerc"' +let b:formatters_c = ['custom_c'] +``` + #### Ranged definitions If your format program supports formatting specific ranges, you can provide a format