Support Conceal for Markdown; disable smartindent

This commit is contained in:
Reed Esau
2014-08-21 21:55:18 -06:00
parent 096dd965d7
commit 55b4a6e690
3 changed files with 207 additions and 168 deletions

View File

@@ -217,6 +217,32 @@ 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
For syntaxes such as [tpope/markdown][tm] which support Vims Conceal
feature, you can display \_*italic*\_, \*\***bold**\*\* and \*\*\****bold
italic***\*\*\* markup where the `_` and `*` characters will be hidden
when youre not on the line. Set the following to `0` if you dont want
this behavior.
```vim
let g:pencil#conceallevel = 2 " 0=disable, 1=onechar, 2=hide (def)
```
Note that to display the _italic_ and **bold** styles in Vim, you may need
both a font (such as [Cousine][co]) with those style variants as well as
a colorscheme (such as [reedes/vim-colors-pencil][cp]) which supports the
Markdown-specific highlight groups.
For more details on Vims Conceal feature, see:
```vim
:help conceallevel
```
[co]: http://www.google.com/fonts/specimen/Cousine
[tm]: http://github.com/tpope/vim-markdown
## Auto-detecting wrap mode ## Auto-detecting wrap mode
If you didn't explicitly specify a wrap mode during initialization, If you didn't explicitly specify a wrap mode during initialization,

View File

@@ -6,7 +6,7 @@
" License: The MIT License (MIT) " License: The MIT License (MIT)
" ============================================================================ " ============================================================================
if exists("autoloaded_pencil") | finish | endif if exists("autoloaded_pencil") | fini | en
let autoloaded_pencil = 1 let autoloaded_pencil = 1
let s:WRAP_MODE_DEFAULT = -1 let s:WRAP_MODE_DEFAULT = -1
@@ -17,7 +17,7 @@ let s:WRAP_MODE_SOFT = 2
" Wrap-mode detector " Wrap-mode detector
" Scan lines at end and beginning of file to determine the wrap mode. " Scan lines at end and beginning of file to determine the wrap mode.
" Modelines has priority over long lines found. " Modelines has priority over long lines found.
function! s:detect_wrap_mode() abort fun! s:detect_wrap_mode() abort
let b:max_textwidth = -1 " assume no relevant modeline let b:max_textwidth = -1 " assume no relevant modeline
call s:doModelines() call s:doModelines()
@@ -25,62 +25,62 @@ function! s:detect_wrap_mode() abort
if b:max_textwidth > 0 if b:max_textwidth > 0
" modelines(s) found with positive textwidth, so hard line breaks " modelines(s) found with positive textwidth, so hard line breaks
return s:WRAP_MODE_HARD return s:WRAP_MODE_HARD
endif en
if b:max_textwidth == 0 || g:pencil#wrapModeDefault ==# 'soft' if b:max_textwidth == 0 || g:pencil#wrapModeDefault ==# 'soft'
" modeline(s) found only with zero textwidth, so it's soft line wrap " modeline(s) found only with zero textwidth, so it's soft line wrap
" or, the user wants to default to soft line wrap " or, the user wants to default to soft line wrap
return s:WRAP_MODE_SOFT return s:WRAP_MODE_SOFT
endif en
" attempt to rule out soft line wrap " attempt to rule out soft line wrap
" scan initial lines in an attempt to detect long lines " scan initial lines in an attempt to detect long lines
for l:line in getline(1, g:pencil#softDetectSample) for l:line in getline(1, g:pencil#softDetectSample)
if len(l:line) > g:pencil#softDetectThreshold if len(l:line) > g:pencil#softDetectThreshold
return s:WRAP_MODE_SOFT return s:WRAP_MODE_SOFT
endif en
endfor endfo
" punt " punt
return s:WRAP_MODE_DEFAULT return s:WRAP_MODE_DEFAULT
endfunction endf
function! s:imap(preserve_completion, key, icmd) fun! s:imap(preserve_completion, key, icmd)
if a:preserve_completion if a:preserve_completion
execute ":inoremap <silent> <expr> " . a:key . " pumvisible() ? \"" . a:key . "\" : \"" . a:icmd . "\"" exe ":ino <silent> <expr> " . a:key . " pumvisible() ? \"" . a:key . "\" : \"" . a:icmd . "\""
else el
execute ":inoremap <silent> " . a:key . " " . a:icmd exe ":ino <silent> " . a:key . " " . a:icmd
endif en
endfunction endf
function! pencil#setAutoFormat(mode) fun! pencil#setAutoFormat(mode)
" 1=auto, 0=manual, -1=toggle " 1=auto, 0=manual, -1=toggle
if !exists('b:last_autoformat') if !exists('b:last_autoformat')
let b:last_autoformat = 0 let b:last_autoformat = 0
endif en
let b:last_autoformat = a:mode == -1 ? !b:last_autoformat : a:mode let b:last_autoformat = a:mode == -1 ? !b:last_autoformat : a:mode
if b:last_autoformat if b:last_autoformat
augroup pencil_autoformat aug pencil_autoformat
autocmd InsertEnter <buffer> set formatoptions+=a au InsertEnter <buffer> set formatoptions+=a
autocmd InsertLeave <buffer> set formatoptions-=a au InsertLeave <buffer> set formatoptions-=a
augroup END aug END
else el
silent! autocmd! pencil_autoformat * <buffer> sil! au! pencil_autoformat * <buffer>
endif en
endfunction endf
" Create mappings for word processing " Create mappings for word processing
" args: " args:
" 'wrap': 'detect|off|hard|soft|toggle' " 'wrap': 'detect|off|hard|soft|toggle'
function! pencil#init(...) abort fun! pencil#init(...) abort
let l:args = a:0 ? a:1 : {} let l:args = a:0 ? a:1 : {}
if !exists('b:wrap_mode') if !exists('b:wrap_mode')
let b:wrap_mode = s:WRAP_MODE_OFF let b:wrap_mode = s:WRAP_MODE_OFF
endif en
if !exists("b:max_textwidth") if !exists("b:max_textwidth")
let b:max_textwidth = -1 let b:max_textwidth = -1
endif en
" If user explicitly requested wrap_mode thru args, go with that. " If user explicitly requested wrap_mode thru args, go with that.
let l:wrap_arg = get(l:args, 'wrap', 'detect') let l:wrap_arg = get(l:args, 'wrap', 'detect')
@@ -88,27 +88,27 @@ function! pencil#init(...) abort
if (b:wrap_mode && l:wrap_arg ==# 'toggle') || if (b:wrap_mode && l:wrap_arg ==# 'toggle') ||
\ l:wrap_arg =~# '^\(0\|off\|disable\|false\)$' \ l:wrap_arg =~# '^\(0\|off\|disable\|false\)$'
let b:wrap_mode = s:WRAP_MODE_OFF let b:wrap_mode = s:WRAP_MODE_OFF
elseif l:wrap_arg ==# 'hard' elsei l:wrap_arg ==# 'hard'
let b:wrap_mode = s:WRAP_MODE_HARD let b:wrap_mode = s:WRAP_MODE_HARD
elseif l:wrap_arg ==# 'soft' elsei l:wrap_arg ==# 'soft'
let b:wrap_mode = s:WRAP_MODE_SOFT let b:wrap_mode = s:WRAP_MODE_SOFT
elseif l:wrap_arg ==# 'default' elsei l:wrap_arg ==# 'default'
let b:wrap_mode = s:WRAP_MODE_DEFAULT let b:wrap_mode = s:WRAP_MODE_DEFAULT
else el
" this can return s:WRAP_MODE_ for soft, hard or default " this can return s:WRAP_MODE_ for soft, hard or default
let b:wrap_mode = s:detect_wrap_mode() let b:wrap_mode = s:detect_wrap_mode()
endif en
" translate default(-1) to soft(1) or hard(2) or off(0) " translate default(-1) to soft(1) or hard(2) or off(0)
if b:wrap_mode == s:WRAP_MODE_DEFAULT if b:wrap_mode == s:WRAP_MODE_DEFAULT
if g:pencil#wrapModeDefault =~# '^\(0\|off\|disable\|false\)$' if g:pencil#wrapModeDefault =~# '^\(0\|off\|disable\|false\)$'
let b:wrap_mode = s:WRAP_MODE_OFF let b:wrap_mode = s:WRAP_MODE_OFF
elseif g:pencil#wrapModeDefault ==# 'soft' elsei g:pencil#wrapModeDefault ==# 'soft'
let b:wrap_mode = s:WRAP_MODE_SOFT let b:wrap_mode = s:WRAP_MODE_SOFT
else el
let b:wrap_mode = s:WRAP_MODE_HARD let b:wrap_mode = s:WRAP_MODE_HARD
endif en
endif en
" autoformat is only used in Hard mode, and then only during " autoformat is only used in Hard mode, and then only during
" Insert mode " Insert mode
@@ -119,24 +119,24 @@ function! pencil#init(...) abort
if b:wrap_mode == s:WRAP_MODE_HARD if b:wrap_mode == s:WRAP_MODE_HARD
if &modeline == 0 && b:max_textwidth > 0 if &modeline == 0 && b:max_textwidth > 0
" Compensate for disabled modeline " Compensate for disabled modeline
execute 'setlocal textwidth=' . b:max_textwidth exe 'setl textwidth=' . b:max_textwidth
elseif &textwidth == 0 elsei &textwidth == 0
execute 'setlocal textwidth=' . g:pencil#textwidth exe 'setl textwidth=' . g:pencil#textwidth
else el
setlocal textwidth< setl textwidth<
endif en
setlocal nowrap setl nowrap
elseif b:wrap_mode == s:WRAP_MODE_SOFT elsei b:wrap_mode == s:WRAP_MODE_SOFT
setlocal textwidth=0 setl textwidth=0
setlocal wrap setl wrap
setlocal linebreak setl linebreak
setlocal colorcolumn=0 " doesn't align as expected setl colorcolumn=0 " doesn't align as expected
else el
setlocal textwidth< setl textwidth<
setlocal wrap< nowrap< setl wrap< nowrap<
setlocal linebreak< nolinebreak< setl linebreak< nolinebreak<
setlocal colorcolumn< setl colorcolumn<
endif en
" global settings " global settings
if b:wrap_mode if b:wrap_mode
@@ -144,122 +144,128 @@ function! pencil#init(...) abort
set backspace=indent,eol,start set backspace=indent,eol,start
if g:pencil#joinspaces if g:pencil#joinspaces
set joinspaces " two spaces after .!? set joinspaces " two spaces after .!?
else el
set nojoinspaces " only one space after a .!? (default) set nojoinspaces " only one space after a .!? (default)
endif en
"if b:wrap_mode == s:WRAP_MODE_SOFT "if b:wrap_mode == s:WRAP_MODE_SOFT
" " augment with additional chars " " augment with additional chars
" " TODO not working yet with n and m-dash " " TODO not working yet with n and m-dash
" set breakat=\ !@*-+;:,./?([{ " set breakat=\ !@*-+;:,./?([{
"endif "en
endif en
" because ve=onemore is relatively rare and could break " because ve=onemore is relatively rare and could break
" other plugins, restrict its presence to buffer " other plugins, restrict its presence to buffer
" Better: restore ve to original setting " Better: restore ve to original setting
if b:wrap_mode && g:pencil#cursorwrap if b:wrap_mode && g:pencil#cursorwrap
set whichwrap+=<,>,b,s,h,l,[,] set whichwrap+=<,>,b,s,h,l,[,]
augroup pencil_cursorwrap aug pencil_cursorwrap
autocmd BufEnter <buffer> set virtualedit+=onemore au BufEnter <buffer> set virtualedit+=onemore
autocmd BufLeave <buffer> set virtualedit-=onemore au BufLeave <buffer> set virtualedit-=onemore
augroup END aug END
else el
silent! autocmd! pencil_cursorwrap * <buffer> sil! au! pencil_cursorwrap * <buffer>
endif en
" window/buffer settings " window/buffer settings
if b:wrap_mode if b:wrap_mode
setlocal nolist setl nolist
setlocal wrapmargin=0 setl wrapmargin=0
setlocal autoindent " needed by formatoptions=n setl autoindent " needed by formatoptions=n
setlocal formatoptions+=n " recognize numbered lists setl nosmartindent " avoid c-style indents in prose
setlocal formatoptions+=1 " don't break line before 1 letter word setl formatoptions+=n " recognize numbered lists
setlocal formatoptions+=t " autoformat of text (vim default) setl formatoptions+=1 " don't break line before 1 letter word
setlocal formatoptions+=c " autoformat of comments (vim default) setl formatoptions+=t " autoformat of text (vim default)
setl formatoptions+=c " autoformat of comments (vim default)
" clean out stuff we likely don't want " clean out stuff we likely don't want
setlocal formatoptions-=2 " use indent of 2nd line for rest of paragraph setl formatoptions-=2 " use indent of 2nd line for rest of paragraph
setlocal formatoptions-=v " only break line at blank entered during insert setl formatoptions-=v " only break line at blank entered during insert
setlocal formatoptions-=w " avoid erratic behavior if mixed spaces setl formatoptions-=w " avoid erratic behavior if mixed spaces
setlocal formatoptions-=a " autoformat will turn on with Insert in HardPencil mode setl formatoptions-=a " autoformat will turn on with Insert in HardPencil mode
setlocal formatoptions-=r " don't insert comment leader setl formatoptions-=r " don't insert comment leader
setlocal formatoptions-=o " don't insert comment leader setl formatoptions-=o " don't insert comment leader
else
setlocal autoindent< noautoindent< exe ":setl cole=" . g:pencil#conceallevel
setlocal list< nolist< el
setlocal wrapmargin< setl smartindent< nosmartindent<
setlocal formatoptions< setl autoindent< noautoindent<
endif setl list< nolist<
setl wrapmargin<
setl formatoptions<
setl cole<
en
if b:wrap_mode == s:WRAP_MODE_SOFT if b:wrap_mode == s:WRAP_MODE_SOFT
nnoremap <buffer> <silent> $ g$ nn <buffer> <silent> $ g$
nnoremap <buffer> <silent> 0 g0 nn <buffer> <silent> 0 g0
vnoremap <buffer> <silent> $ g$ vn <buffer> <silent> $ g$
vnoremap <buffer> <silent> 0 g0 vn <buffer> <silent> 0 g0
noremap <buffer> <silent> <Home> g<Home> no <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End> no <buffer> <silent> <End> g<End>
" preserve behavior of home/end keys in popups " preserve behavior of home/end keys in popups
call s:imap(1, '<Home>', '<C-o>g<Home>') call s:imap(1, '<Home>', '<C-o>g<Home>')
call s:imap(1, '<End>' , '<C-o>g<End>' ) call s:imap(1, '<End>' , '<C-o>g<End>' )
else el
silent! nunmap <buffer> $ sil! nun <buffer> $
silent! nunmap <buffer> 0 sil! nun <buffer> 0
silent! vunmap <buffer> $ sil! vu <buffer> $
silent! vunmap <buffer> 0 sil! vu <buffer> 0
silent! nunmap <buffer> <Home> sil! nun <buffer> <Home>
silent! nunmap <buffer> <End> sil! nun <buffer> <End>
silent! iunmap <buffer> <Home> sil! iu <buffer> <Home>
silent! iunmap <buffer> <End> sil! iu <buffer> <End>
endif en
if b:wrap_mode if b:wrap_mode
nnoremap <buffer> <silent> j gj nn <buffer> <silent> j gj
nnoremap <buffer> <silent> k gk nn <buffer> <silent> k gk
vnoremap <buffer> <silent> j gj vn <buffer> <silent> j gj
vnoremap <buffer> <silent> k gk vn <buffer> <silent> k gk
noremap <buffer> <silent> <Up> gk no <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj no <buffer> <silent> <Down> gj
" preserve behavior of up/down keys in popups " preserve behavior of up/down keys in popups
call s:imap(1, '<Up>' , '<C-o>g<Up>' ) call s:imap(1, '<Up>' , '<C-o>g<Up>' )
call s:imap(1, '<Down>', '<C-o>g<Down>') call s:imap(1, '<Down>', '<C-o>g<Down>')
else el
silent! nunmap <buffer> j sil! nun <buffer> j
silent! nunmap <buffer> k sil! nun <buffer> k
silent! vunmap <buffer> j sil! vu <buffer> j
silent! vunmap <buffer> k sil! vu <buffer> k
silent! unmap <buffer> <Up> sil! unm <buffer> <Up>
silent! unmap <buffer> <Down> sil! unm <buffer> <Down>
silent! iunmap <buffer> <Up> sil! iu <buffer> <Up>
silent! iunmap <buffer> <Down> sil! iu <buffer> <Down>
endif en
" set undo points around common punctuation, " set undo points around common punctuation,
" line <c-u> and word <c-w> deletions " line <c-u> and word <c-w> deletions
if b:wrap_mode if b:wrap_mode
inoremap <buffer> . .<c-g>u ino <buffer> . .<c-g>u
inoremap <buffer> ! !<c-g>u ino <buffer> ! !<c-g>u
inoremap <buffer> ? ?<c-g>u ino <buffer> ? ?<c-g>u
inoremap <buffer> , ,<c-g>u ino <buffer> , ,<c-g>u
inoremap <buffer> ; ;<c-g>u ino <buffer> ; ;<c-g>u
inoremap <buffer> : :<c-g>u ino <buffer> : :<c-g>u
inoremap <buffer> <c-u> <c-g>u<c-u> ino <buffer> <c-u> <c-g>u<c-u>
inoremap <buffer> <c-w> <c-g>u<c-w> ino <buffer> <c-w> <c-g>u<c-w>
inoremap <buffer> <cr> <c-g>u<cr> ino <buffer> <cr> <c-g>u<cr>
else el
silent! iunmap <buffer> . sil! iu <buffer> .
silent! iunmap <buffer> ! sil! iu <buffer> !
silent! iunmap <buffer> ? sil! iu <buffer> ?
silent! iunmap <buffer> , sil! iu <buffer> ,
silent! iunmap <buffer> ; sil! iu <buffer> ;
silent! iunmap <buffer> : sil! iu <buffer> :
silent! iunmap <buffer> <c-u> sil! iu <buffer> <c-u>
silent! iunmap <buffer> <c-w> sil! iu <buffer> <c-w>
silent! iunmap <buffer> <cr> sil! iu <buffer> <cr>
endif en
endfunction endf
" attempt to find a non-zero textwidth, etc. " attempt to find a non-zero textwidth, etc.
fun! s:doOne(item) abort fun! s:doOne(item) abort
@@ -269,10 +275,10 @@ fun! s:doOne(item) abort
let l:tw = str2nr(l:matches[2]) let l:tw = str2nr(l:matches[2])
if l:tw > b:max_textwidth if l:tw > b:max_textwidth
let b:max_textwidth = l:tw let b:max_textwidth = l:tw
endif en
endif en
endif en
endfun endf
" attempt to find a non-zero textwidth, etc. " attempt to find a non-zero textwidth, etc.
fun! s:doModeline(line) abort fun! s:doModeline(line) abort
@@ -280,15 +286,15 @@ fun! s:doModeline(line) abort
if len(l:matches) > 0 if len(l:matches) > 0
for l:item in split(l:matches[3]) for l:item in split(l:matches[3])
call s:doOne(l:item) call s:doOne(l:item)
endfor endfo
endif en
let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\(.\+\)') let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\(.\+\)')
if len(l:matches) > 0 if len(l:matches) > 0
for l:item in split(l:matches[3], '[ \t:]') for l:item in split(l:matches[3], '[ \t:]')
call s:doOne(l:item) call s:doOne(l:item)
endfor endfo
endif en
endfun endf
" sample lines for detection, capturing both " sample lines for detection, capturing both
" modeline(s) and max line length " modeline(s) and max line length
@@ -301,12 +307,12 @@ fun! s:doModelines() abort
\ 'v:val =~ ":"'), 'extend(l:lines, { v:val : 0 } )') \ 'v:val =~ ":"'), 'extend(l:lines, { v:val : 0 } )')
for l:line in keys(l:lines) for l:line in keys(l:lines)
call s:doModeline(l:line) call s:doModeline(l:line)
endfor endfo
else el
for l:line in getline(1, "$") for l:line in getline(1, "$")
call s:doModeline(l:line) call s:doModeline(l:line)
endfor endfo
endif en
endfun endf
" vim:ts=2:sw=2:sts=2 " vim:ts=2:sw=2:sts=2

View File

@@ -6,7 +6,7 @@
" License: The MIT License (MIT) " License: The MIT License (MIT)
" ============================================================================ " ============================================================================
" "
if exists('g:loaded_pencil') || &cp | finish | endif if exists('g:loaded_pencil') || &cp | fini | en
let g:loaded_pencil = 1 let g:loaded_pencil = 1
" Save 'cpoptions' and set Vim default to enable line continuations. " Save 'cpoptions' and set Vim default to enable line continuations.
@@ -17,53 +17,60 @@ if !exists('g:pencil#wrapModeDefault')
" user-overridable default, if detection fails " user-overridable default, if detection fails
" should be 'soft' or 'hard' or 'off' " should be 'soft' or 'hard' or 'off'
let g:pencil#wrapModeDefault = 'hard' let g:pencil#wrapModeDefault = 'hard'
endif en
if !exists('g:pencil#textwidth') if !exists('g:pencil#textwidth')
" textwidth used when in hard linebreak mode " textwidth used when in hard linebreak mode
let g:pencil#textwidth = 74 let g:pencil#textwidth = 74
endif en
if !exists('g:pencil#autoformat') if !exists('g:pencil#autoformat')
" by default, automatically format text when in Insert mode " by default, automatically format text when in Insert mode
" with hard wrap. " with hard wrap.
let g:pencil#autoformat = 1 let g:pencil#autoformat = 1
endif en
if !exists('g:pencil#joinspaces') if !exists('g:pencil#joinspaces')
" by default, only one space after full stop (.) " by default, only one space after full stop (.)
let g:pencil#joinspaces = 0 let g:pencil#joinspaces = 0
endif en
if !exists('g:pencil#cursorwrap') if !exists('g:pencil#cursorwrap')
" by default, h/l and cursor keys will wrap around hard " by default, h/l and cursor keys will wrap around hard
" linebreaks. Set to 0 if you don't want this behavior " linebreaks. Set to 0 if you don't want this behavior
let g:pencil#cursorwrap = 1 let g:pencil#cursorwrap = 1
endif en
if !exists('g:pencil#conceallevel')
" by default, concealing capability in your syntax plugin
" will be enabled. See tpope/vim-markdown for example.
" Set to 0 if you don't want this behavior
let g:pencil#conceallevel = 2
en
if !exists('g:pencil#softDetectSample') if !exists('g:pencil#softDetectSample')
" if no modeline, read as many as this many lines at " if no modeline, read as many as this many lines at
" start of file in attempt to detect at least one line " start of file in attempt to detect at least one line
" whose byte count exceeds g:pencil#softDetectThreshold " whose byte count exceeds g:pencil#softDetectThreshold
let g:pencil#softDetectSample = 20 let g:pencil#softDetectSample = 20
endif en
if !exists('g:pencil#softDetectThreshold') if !exists('g:pencil#softDetectThreshold')
" if the byte count of at least one sampled line exceeds " if the byte count of at least one sampled line exceeds
" this number, then pencil assumes soft line wrapping " this number, then pencil assumes soft line wrapping
let g:pencil#softDetectThreshold = 130 let g:pencil#softDetectThreshold = 130
endif en
" # Commands " # coms
command -nargs=0 HardPencil call pencil#init({'wrap': 'hard'}) com -nargs=0 HardPencil call pencil#init({'wrap': 'hard'})
command -nargs=0 SoftPencil call pencil#init({'wrap': 'soft'}) com -nargs=0 SoftPencil call pencil#init({'wrap': 'soft'})
command -nargs=0 DropPencil call pencil#init({'wrap': 'off' }) com -nargs=0 DropPencil call pencil#init({'wrap': 'off' })
command -nargs=0 NoPencil call pencil#init({'wrap': 'off' }) com -nargs=0 NoPencil call pencil#init({'wrap': 'off' })
command -nargs=0 TogglePencil call pencil#init({'wrap': 'toggle'}) com -nargs=0 TogglePencil call pencil#init({'wrap': 'toggle'})
command -nargs=0 AutoPencil call pencil#setAutoFormat(1) com -nargs=0 AutoPencil call pencil#setAutoFormat(1)
command -nargs=0 ManualPencil call pencil#setAutoFormat(0) com -nargs=0 ManualPencil call pencil#setAutoFormat(0)
command -nargs=0 ShiftPencil call pencil#setAutoFormat(-1) com -nargs=0 ShiftPencil call pencil#setAutoFormat(-1)
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo