From 72d0a6d5f7a03d5037d46e8d633229c321b3a305 Mon Sep 17 00:00:00 2001 From: Reed Esau Date: Sat, 10 Jan 2015 12:58:15 -0700 Subject: [PATCH] Additional tweaks for #25 Further improvements to README as well. --- README.markdown | 20 +++++++++++++------- autoload/pencil.vim | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.markdown b/README.markdown index 8632d2f..8923b4c 100644 --- a/README.markdown +++ b/README.markdown @@ -215,7 +215,7 @@ Because auto-detect might not work as intended, you can invoke a command to set the behavior for the current buffer: * `PencilSoft` - initialize _pencil_ with soft line wrap mode -* `PencilHard` - initialize _pencil_ with hard line break mode (and autoformat) +* `PencilHard` - initialize _pencil_ with hard line break mode (and Vim’s autoformat) ## Automatic formatting @@ -226,16 +226,17 @@ When inserting text while in *PencilHard* mode, Vim’s autoformat feature will be enabled by default and can offer many of the same benefits as soft line wrap. -A useful exception: if used with popular prose-oriented syntax plugins, +One useful exception: if used with popular prose-oriented syntax plugins, _pencil_ will **disable** autoformat when you enter Insert mode from inside a code block or table. (See the advanced section below for more -details.) +details on the blacklisting feature.) -Where you need to manually enable/disable autoformat, you can do so with a command: +Where you need to manually enable/disable autoformat for the current +buffer, you can do so with a command: -* `PFormat` - enables autoformat -* `PFormatOff` - disables autoformat -* `PFormatToggle` - toggle to enable if disabled, etc. +* `PFormat` - allows autoformat to be enabled (if not blacklisted) +* `PFormatOff` - prevents autoformat from enabling (blacklist all) +* `PFormatToggle` - toggle to allow if off, etc. To set the default behavior, add to your `.vimrc`: @@ -466,6 +467,11 @@ let g:pencil#autoformat_blacklist = [ \ ] ``` +_WARNING: the implementation of this blacklist may be changing in the +future._ + +There’s also a whitelist to override the blacklist. See code for details. + You can override this in your `.vimrc`. Additions to defaults with good use cases are welcome. diff --git a/autoload/pencil.vim b/autoload/pencil.vim index 7a54708..65ad16f 100644 --- a/autoload/pencil.vim +++ b/autoload/pencil.vim @@ -103,7 +103,7 @@ fun! s:maybe_enable_autoformat() " either of which greenlights a whitelist check if !l:found_empty if synstack(l:line, 1) == [] || - \ (l:last_col > 2 && synstack(l:line, l:last_col-1) == []) + \ (l:last_col > 1 && synstack(l:line, l:last_col-1) == []) let l:found_empty = 1 en en