Работа с чекбоксами и радиокнопками
parent
b01298bcdf
commit
e606979a16
30
README.md
30
README.md
|
|
@ -1,3 +1,29 @@
|
|||
# vim-md
|
||||
Vim Markdown
|
||||
============
|
||||
|
||||
ftplugin для markdown
|
||||
ftplugin для работы c markdown разметкой.
|
||||
|
||||
|
||||
Возможности
|
||||
-----------
|
||||
|
||||
- Фолдинг и установка чекбоксов и радиокнопок
|
||||
|
||||
|
||||
Установка
|
||||
---------
|
||||
|
||||
```shell
|
||||
mkdir ~/.vim/ftplugin
|
||||
curl https://code.geekfrom.ru/i/vim-md/raw/branch/master/ftplugin/markdown.vim > ~/.vim/ftplufin/markdown.vim
|
||||
```
|
||||
|
||||
|
||||
Mappings
|
||||
--------
|
||||
|
||||
|description|modes|mapping|
|
||||
|-----------|-----|-------|
|
||||
|Установить/убрать радиокнопку|normal, visual|`<leader>r`|
|
||||
|Установить/убрать чекбокс|normal, visual|`<leader>c`|
|
||||
|Переключить чекбокс/радиокнопку|normal, visual|`<leader>t`|
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" File: ftplugin/markdown.vim
|
||||
" Maintainer: Andrew Nechaev <i@geekfrom.ru>
|
||||
" Version: 0.0.1
|
||||
" Modified: 2022-05-13 18:30+0400
|
||||
" License: MIT
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
nnoremap <buffer> <silent> <Leader>t :call winrestview(<SID>toggle('^\s*[-+*]\s*[\[(]\zs.\ze[\])]', {' ': 'x', 'x': '-', '-': ' '}))<cr>
|
||||
vnoremap <buffer> <silent> <Leader>t :call winrestview(<SID>toggle('^\s*[-+*]\s*[\[(]\zs.\ze[\])]', {' ': 'x', 'x': '-', '-': ' '}))<cr>
|
||||
|
||||
nnoremap <buffer> <silent> <Leader>r :call winrestview(<SID>toggleState('(', '( ) '))<cr>
|
||||
vnoremap <buffer> <silent> <Leader>r :call winrestview(<SID>toggleState('(', '( ) '))<cr>
|
||||
nnoremap <buffer> <silent> <Leader>c :call winrestview(<SID>toggleState('[', '[ ] '))<cr>
|
||||
vnoremap <buffer> <silent> <Leader>c :call winrestview(<SID>toggleState('[', '[ ] '))<cr>
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue