mirror of
https://github.com/preservim/vim-pencil.git
synced 2025-11-16 22:03:39 -05:00
Added section on advance configuration
This commit is contained in:
@@ -14,8 +14,8 @@ The _pencil_ plugin aspires to make Vim as powerful a tool for writers as
|
|||||||
it is for coders by focusing narrowly on the handful of tweaks needed to
|
it is for coders by focusing narrowly on the handful of tweaks needed to
|
||||||
smooth the path to writing prose.
|
smooth the path to writing prose.
|
||||||
|
|
||||||
* For editing prose-oriented file types such as _text_, _markdown_, and
|
* For editing prose-oriented file types such as _text_, _markdown_,
|
||||||
_textile_
|
_mail_, _rst_, and _textile_.
|
||||||
* Agnostic on soft line wrap _versus_ hard line breaks, supporting both
|
* Agnostic on soft line wrap _versus_ hard line breaks, supporting both
|
||||||
* Auto-detects wrap mode via modeline and sampling
|
* Auto-detects wrap mode via modeline and sampling
|
||||||
* Adjusts navigation key mappings to suit the wrap mode
|
* Adjusts navigation key mappings to suit the wrap mode
|
||||||
@@ -100,19 +100,17 @@ let g:pencil#wrapModeDefault = 'hard' " or 'soft'
|
|||||||
augroup pencil
|
augroup pencil
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType markdown,mkd call pencil#init()
|
autocmd FileType markdown,mkd call pencil#init()
|
||||||
autocmd FileType textile call pencil#init()
|
|
||||||
autocmd FileType text call pencil#init({'wrap': 'hard'})
|
autocmd FileType text call pencil#init({'wrap': 'hard'})
|
||||||
augroup END
|
augroup END
|
||||||
```
|
```
|
||||||
|
|
||||||
In the example above, for files of type `markdown` and `textile`, this
|
In the example above, for files of type `markdown` this plugin will
|
||||||
plugin will auto-detect the line wrap approach, with `hard` as the
|
auto-detect the line wrap approach, with hard line breaks as the default.
|
||||||
default. But for files of type `text`, it will *always* initialize with
|
|
||||||
hard line break mode.
|
|
||||||
|
|
||||||
Configurable options for `pencil#init()` include: `autoformat`,
|
For files of type `text`, it will initialize with hard line breaks, even
|
||||||
`concealcursor`, `conceallevel`, `cursorwrap`, `joinspaces`, `textwidth`,
|
if auto-detect might suggest soft line wrap.
|
||||||
and `wrap`.
|
|
||||||
|
For more details, see “Advanced initialization” below.
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
@@ -291,6 +289,51 @@ has not been initialized.
|
|||||||
|
|
||||||
[va]: http://github.com/bling/vim-airline
|
[va]: http://github.com/bling/vim-airline
|
||||||
|
|
||||||
|
### Advanced initialization
|
||||||
|
|
||||||
|
Configurable options for `pencil#init()` include: `autoformat`,
|
||||||
|
`concealcursor`, `conceallevel`, `cursorwrap`, `joinspaces`, `textwidth`,
|
||||||
|
and `wrap`. These are detailed above.
|
||||||
|
|
||||||
|
You can set additional options in your `autocmd` statements, such as to
|
||||||
|
initialize other prose-oriented plugins, tweak settings and add key
|
||||||
|
mappings:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
augroup pencil
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType markdown,mkd call pencil#init() |
|
||||||
|
\ call lexical#init() |
|
||||||
|
\ call litecorrect#init() |
|
||||||
|
\ call textobj#quote#init() |
|
||||||
|
\ call textobj#sentence#init() |
|
||||||
|
\ setlocal ruler nonumber |
|
||||||
|
\ nnoremap <silent> Q gwip
|
||||||
|
augroup END
|
||||||
|
```
|
||||||
|
|
||||||
|
A more advanced example:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
augroup pencil
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType markdown,mkd call pencil#init() |
|
||||||
|
\ call litecorrect#init() |
|
||||||
|
\ setl spell spl=en_us fdl=4 noru nonu nornu |
|
||||||
|
\ setl fdo+=search
|
||||||
|
autocmd Filetype git,gitsendemail,*commit*,*COMMIT* |
|
||||||
|
\ call pencil#init({'wrap': 'hard', 'textwidth': 72}) |
|
||||||
|
\ call litecorrect#init() |
|
||||||
|
\ setl spell spl=en_us et sw=2 ts=2 noai
|
||||||
|
autocmd Filetype mail call pencil#init({'wrap': 'hard', 'textwidth': 60}) |
|
||||||
|
\ call litecorrect#init() |
|
||||||
|
\ setl spell spl=en_us et sw=2 ts=2 noai nonu nornu
|
||||||
|
autocmd Filetype html,xml call pencil#init({'wrap': 'soft'}) |
|
||||||
|
\ call litecorrect#init() |
|
||||||
|
\ setl spell spl=en_us et sw=2 ts=2
|
||||||
|
augroup END
|
||||||
|
```
|
||||||
|
|
||||||
## Auto-detecting wrap mode
|
## Auto-detecting wrap mode
|
||||||
|
|
||||||
**(For advanced users looking to tweak _pencil's_ behavior.)**
|
**(For advanced users looking to tweak _pencil's_ behavior.)**
|
||||||
|
|||||||
Reference in New Issue
Block a user