From 55f0e34e3a701a2a50e3b7255bce9aeb51cebe93 Mon Sep 17 00:00:00 2001 From: jdhao Date: Sat, 31 Jul 2021 21:14:44 +0800 Subject: [PATCH] chore: update docs and code for markdown list function --- after/ftplugin/markdown.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim index f0b9d80..577e9bf 100644 --- a/after/ftplugin/markdown.vim +++ b/after/ftplugin/markdown.vim @@ -16,6 +16,7 @@ onoremap ic :call text_obj#MdCodeBlock('i') onoremap ac :call text_obj#MdCodeBlock('a') " Use + to turn several lines to an unordered list. +" Ref: https://vi.stackexchange.com/q/5495/15292 and https://stackoverflow.com/q/42438795/6064933. nnoremap + :set operatorfunc=AddListSymbolg@ xnoremap + : call AddListSymbol(visualmode(), 1) @@ -32,11 +33,11 @@ function! AddListSymbol(type, ...) abort for line in range(line_start, line_end) let text = getline(line) - let end = matchend(text, '^\s*') - if end == 0 + let l:end = matchend(text, '^\s*') + if l:end == 0 let new_text = '+ ' . text else - let new_text = text[0:end-1] . ' + ' . text[end:] + let new_text = text[0 : l:end-1] . ' + ' . text[l:end :] endif call setline(line, new_text)