"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " File: ftplugin/markdown.vim " Maintainer: Andrew Nechaev " Version: 0.0.1 " Modified: 2022-05-13 18:30+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 r :call winrestview(toggleState('(', '( ) ')) vnoremap r :call winrestview(toggleState('(', '( ) ')) nnoremap c :call winrestview(toggleState('[', '[ ] ')) vnoremap c :call winrestview(toggleState('[', '[ ] ')) set tabstop=2 softtabstop=2 shiftwidth=2 expandtab function s:toggle(pattern, dict, ...) let view = winsaveview() execute 'keeppatterns s/' . a:pattern . '/\=get(a:dict, submatch(0), a:0 ? a:1 : " ")/e' return view endfunction function s:toggleState(search, replacement) let view = winsaveview() execute 'keeppatterns s/^\s*\(-\s*\|+\s*\|*\s\)\?\zs\(\[.\]\|(.)\)\?\s*\ze/\=match(submatch(0), a:search) != -1 ? "" : a:replacement/e' return view endfunction