diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index d8d312b..820e485 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -1,13 +1,13 @@ """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " File: ftplugin/markdown.vim " Maintainer: Andrew Nechaev -" Version: 0.0.1 -" Modified: 2022-05-13 18:30+0400 +" Version: 0.1.0 +" Modified: 2022-05-13 21:00+0400 " License: MIT """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -nnoremap t :call winrestview(toggle('^\s*[-+*]\s*[\[(]\zs.\ze[\])]', {' ': 'x', 'x': '-', '-': ' '})) -vnoremap t :call winrestview(toggle('^\s*[-+*]\s*[\[(]\zs.\ze[\])]', {' ': 'x', 'x': '-', '-': ' '})) +nnoremap t :call winrestview(toggle({' ': 'x', 'x': '-', '-': ' '})) +vnoremap t :call winrestview(toggle({' ': 'x', 'x': '-', '-': ' '})) nnoremap r :call winrestview(toggleState('(', '( ) ')) vnoremap r :call winrestview(toggleState('(', '( ) ')) @@ -16,9 +16,9 @@ vnoremap c :call winrestview(toggleState('[', '[ set tabstop=2 softtabstop=2 shiftwidth=2 expandtab -function s:toggle(pattern, dict, ...) +function s:toggle(dict) let view = winsaveview() - execute 'keeppatterns s/' . a:pattern . '/\=get(a:dict, submatch(0), a:0 ? a:1 : " ")/e' + execute 'keeppatterns s/^\s*\(-\s*\|+\s*\|*\s\)\?\s*[\[(]\zs.\ze[\])]/\=get(a:dict, submatch(0), a:0 ? a:1 : " ")/e' return view endfunction