Better docs and new defaults for Vim's conceal feature

This commit is contained in:
Reed Esau
2014-08-24 23:46:18 -06:00
parent 78c8b46f91
commit 74e5b86409
3 changed files with 36 additions and 23 deletions

View File

@@ -25,9 +25,8 @@ smooth the path to writing prose.
* Buffer-scoped configuration (with a few minor exceptions, _pencil_ * Buffer-scoped configuration (with a few minor exceptions, _pencil_
preserves your global settings) preserves your global settings)
* Pure Vimscript with no dependencies * Pure Vimscript with no dependencies
* Support for Vims Conceal feature to hide `_` and `*` characters when * Support for Vims Conceal feature to hide `_` and `*` markup for
displaying \_*italic*\_, \*\*__bold__\*\* and \*\*\*___bold \_*italic*\_, \*\*__bold__\*\* and \*\*\*___bold italic___\*\*\* styled text in Markdown
italic___\*\*\* styled text in Markdown
Need spell-check and other features? Vim is about customization. To Need spell-check and other features? Vim is about customization. To
complete your editing environment, learn to configure Vim and draw upon complete your editing environment, learn to configure Vim and draw upon
@@ -220,34 +219,42 @@ a hard break. If you wish to retain the default Vim behavior, set the
let g:pencil#cursorwrap = 1 " 0=disable, 1=enable (def) let g:pencil#cursorwrap = 1 " 0=disable, 1=enable (def)
``` ```
### Concealing markup in Markdown ### Concealing \_\_styling markup\_\_ in Markdown
Syntaxes such as [tpope/vim-markdown][tm] support Vims Conceal feature, Syntax plugins such as [tpope/vim-markdown][tm] support Vims Conceal
where the `_` and `*` characters will be hidden automatically when feature, where the `_` and `*` characters can be hidden automatically when
displaying \_*italic*\_, \*\*__bold__\*\* and \*\*\*___bold displaying \_*italic*\_, \*\*__bold__\*\* and \*\*\*___bold
italic___\*\*\* styled text. To enable, set the following to `2` in your italic___\*\*\* styled text.
`.vimrc`:
```vim To use Vims Conceal feature with Markdown, you will need to install:
let g:pencil#conceallevel = 2 " 0=disable (def), 1=onechar, 2=autohide
```
A couple of things you will need: 1. [tpope/vim-markdown][tm] as its currently the only Markdown syntax
plugin that supports conceal.
1. a font (such as [Cousine][co]) featuring the _italic_, **bold**, 2. a font (such as [Cousine][co]) featuring the _italic_, **bold**,
and ***bold italic*** style variants and ***bold italic*** style variants
2. a colorscheme (such as [reedes/vim-colors-pencil][cp]) which 3. a colorscheme (such as [reedes/vim-colors-pencil][cp]) which
supports the Markdown-specific highlight groups. supports the Markdown-specific highlight groups.
Terminal users: sadly, the ***bold italic*** style wont be available. You should then only see the `_` and `*` markup when in visual or insert
Consult your terminals documentation to configure your terminal to mode. The markup will be concealed in normal and command mode.
support **bold** and _italic_ styles.
You can change _pencils_ default settings for conceal in your `.vimrc`:
```vim
let g:pencil#conceallevel = 3 " 0=disable, 1=onechar, 2=hidechar, 3=hideall
let g:pencil#concealcursor = 'nc' " n=normal, v=visual, i=insert, c=command
```
Terminal users: consult your terminals documentation to configure your
terminal to support **bold** and _italic_ styles.
For more details on Vims Conceal feature, see: For more details on Vims Conceal feature, see:
```vim ```vim
:help conceallevel :help conceallevel
:help concealcursor
``` ```
[co]: http://www.google.com/fonts/specimen/Cousine [co]: http://www.google.com/fonts/specimen/Cousine

View File

@@ -187,8 +187,9 @@ fun! pencil#init(...) abort
setl formatoptions-=r " don't insert comment leader setl formatoptions-=r " don't insert comment leader
setl formatoptions-=o " don't insert comment leader setl formatoptions-=o " don't insert comment leader
if has("conceal") if has('conceal')
exe ":setl cole=" . g:pencil#conceallevel exe ':setl conceallevel=' . g:pencil#conceallevel
exe ':setl concealcursor=' . g:pencil#concealcursor
en en
el el
setl smartindent< nosmartindent< setl smartindent< nosmartindent<
@@ -196,8 +197,9 @@ fun! pencil#init(...) abort
setl list< nolist< setl list< nolist<
setl wrapmargin< setl wrapmargin<
setl formatoptions< setl formatoptions<
if has("conceal") if has('conceal')
setl cole< setl conceallevel<
setl concealcursor<
en en
en en

View File

@@ -44,8 +44,12 @@ en
if !exists('g:pencil#conceallevel') if !exists('g:pencil#conceallevel')
" by default, concealing capability in your syntax plugin " by default, concealing capability in your syntax plugin
" will be enabled. See tpope/vim-markdown for example. " will be enabled. See tpope/vim-markdown for example.
" 0=disable (def), 1=onechar, 2=autohide " 0=disable, 1=onechar, 2=hidecust, 3=hideall
let g:pencil#conceallevel = 0 let g:pencil#conceallevel = 3
en
if !exists('g:pencil#concealcursor')
" n=normal, v=visual, i=insert, c=command
let g:pencil#concealcursor = 'nc'
en en
if !exists('g:pencil#softDetectSample') if !exists('g:pencil#softDetectSample')