mirror of
https://github.com/preservim/vim-pencil.git
synced 2025-11-14 04:43:47 -05:00
Improve initialization recommendations further.
This commit is contained in:
@@ -81,6 +81,35 @@ tutorials available._
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
### Basic configuration
|
||||||
|
|
||||||
|
```vim
|
||||||
|
set nocompatible
|
||||||
|
filetype plugin on " may already be in your .vimrc
|
||||||
|
|
||||||
|
augroup pencil
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType markdown,mkd call pencil#init()
|
||||||
|
autocmd FileType text call pencil#init()
|
||||||
|
augroup END
|
||||||
|
```
|
||||||
|
|
||||||
|
You can initialize several prose-oriented plugins together:
|
||||||
|
|
||||||
|
```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()
|
||||||
|
augroup END
|
||||||
|
```
|
||||||
|
|
||||||
|
For more details, see [Advanced initialization](#advanced-initialization)
|
||||||
|
below.
|
||||||
|
|
||||||
### Hard line breaks or soft line wrap?
|
### Hard line breaks or soft line wrap?
|
||||||
|
|
||||||
Coders will have the most experience with the former, and writers the
|
Coders will have the most experience with the former, and writers the
|
||||||
@@ -89,13 +118,10 @@ with both conventions. This plugin doesn't force you to choose a side—you
|
|||||||
can configure each buffer independently.
|
can configure each buffer independently.
|
||||||
|
|
||||||
In most cases you can set a default to suit your preference and let
|
In most cases you can set a default to suit your preference and let
|
||||||
auto-detection figure out what to do. Add to your `.vimrc`:
|
auto-detection figure out what to do.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
set nocompatible
|
let g:pencil#wrapModeDefault = 'soft' " or 'hard'
|
||||||
filetype plugin on " may already be in your .vimrc
|
|
||||||
|
|
||||||
let g:pencil#wrapModeDefault = 'hard' " or 'soft'
|
|
||||||
|
|
||||||
augroup pencil
|
augroup pencil
|
||||||
autocmd!
|
autocmd!
|
||||||
@@ -105,14 +131,11 @@ augroup END
|
|||||||
```
|
```
|
||||||
|
|
||||||
In the example above, for files of type `markdown` this plugin will
|
In the example above, for files of type `markdown` this plugin will
|
||||||
auto-detect the line wrap approach, with hard line breaks as the default.
|
auto-detect the line wrap approach, with soft line wrap as the default.
|
||||||
|
|
||||||
For files of type `text`, it will initialize with hard line breaks, even
|
For files of type `text`, it will initialize with hard line breaks, even
|
||||||
if auto-detect might suggest soft line wrap.
|
if auto-detect might suggest soft line wrap.
|
||||||
|
|
||||||
For more details, see [Advanced initialization](#advanced-initialization)
|
|
||||||
below.
|
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
Because auto-detect might not work as intended, you can invoke a command
|
Because auto-detect might not work as intended, you can invoke a command
|
||||||
@@ -296,24 +319,8 @@ Configurable options for `pencil#init()` include: `autoformat`,
|
|||||||
`concealcursor`, `conceallevel`, `cursorwrap`, `joinspaces`, `textwidth`,
|
`concealcursor`, `conceallevel`, `cursorwrap`, `joinspaces`, `textwidth`,
|
||||||
and `wrap`. These are detailed above.
|
and `wrap`. These are detailed above.
|
||||||
|
|
||||||
You can set additional options in your `autocmd` statements, such as to
|
Comprehensive initialization is possible without having to populate
|
||||||
initialize other prose-oriented plugins, tweak settings and add key
|
`after/ftplugin` modules:
|
||||||
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 <buffer> <silent> Q gwip
|
|
||||||
augroup END
|
|
||||||
```
|
|
||||||
|
|
||||||
A more advanced example:
|
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
augroup pencil
|
augroup pencil
|
||||||
@@ -335,6 +342,9 @@ augroup pencil
|
|||||||
augroup END
|
augroup END
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatives to initialize include `after/ftplugin` modules as well as
|
||||||
|
refactoring statements into a function.
|
||||||
|
|
||||||
## 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