aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-04 19:38:52 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-04 19:38:52 +1200
commit9c539c41dcfdf68e5573fc7c9d64e5d2d1db5e5a (patch)
treeca06769ff7cba6be46e219389797ad9d389bd877 /vim/after/ftplugin
parentUse case-insensitive Vim ==# (diff)
downloaddotfiles-9c539c41dcfdf68e5573fc7c9d64e5d2d1db5e5a.tar.gz
dotfiles-9c539c41dcfdf68e5573fc7c9d64e5d2d1db5e5a.zip
Rearrange/correct markdown_autoformat.vim
Diffstat (limited to 'vim/after/ftplugin')
-rw-r--r--vim/after/ftplugin/markdown/autoformat.vim28
1 files changed, 9 insertions, 19 deletions
diff --git a/vim/after/ftplugin/markdown/autoformat.vim b/vim/after/ftplugin/markdown/autoformat.vim
index b2152336..78a2c23a 100644
--- a/vim/after/ftplugin/markdown/autoformat.vim
+++ b/vim/after/ftplugin/markdown/autoformat.vim
@@ -38,8 +38,9 @@ if !has('*s:Load')
endif
endfunction
endif
+call s:Load()
-" Suspend auto-format when pasting anything with a linebreak
+" Suspend auto-formatting when in a code block (four-space indent)
if !has('*s:Line')
function! s:Line() abort
if getline('.') =~# '\m^ '
@@ -53,8 +54,14 @@ if !has('*s:Line')
endif
endfunction
endif
+augroup ftplugin_markdown_autoformat
+ autocmd!
+ autocmd BufWinEnter,CursorMoved,CursorMovedI,WinEnter
+ \ <buffer>
+ \ call s:Line()
+augroup END
-" Suspend auto-formatting when in a code block (four-space indent)
+" Suspend auto-format when pasting anything with a linebreak
if !has('*s:Put')
function! s:Put(above) abort
let l:suspended = 0
@@ -72,23 +79,6 @@ if !has('*s:Put')
endif
endfunction
endif
-
-" Turn on autoformatting if the buffer has no code-block lines with spaces
-" that is longer than 'textwidth'
-call s:Load()
-
-" Group autocommands
-augroup ftplugin_markdown_autoformat
- autocmd!
-
- " Suspend auto-formatting when in a code block (four-space indent)
- autocmd BufWinEnter,CursorMoved,CursorMovedI,WinEnter
- \ <buffer>
- \ call s:Line()
-
-augroup END
-
-" Suspend auto-format when pasting anything with a linebreak
nnoremap <buffer> <silent>
\ p
\ :<C-u>call <SID>Put(0)<CR>