mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
chore: update docs and code for markdown list function
This commit is contained in:
parent
ce5710be00
commit
55f0e34e3a
@ -16,6 +16,7 @@ onoremap <buffer><silent> ic :<C-U>call text_obj#MdCodeBlock('i')<CR>
|
|||||||
onoremap <buffer><silent> ac :<C-U>call text_obj#MdCodeBlock('a')<CR>
|
onoremap <buffer><silent> ac :<C-U>call text_obj#MdCodeBlock('a')<CR>
|
||||||
|
|
||||||
" Use + to turn several lines to an unordered list.
|
" 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 <buffer><silent> + :set operatorfunc=AddListSymbol<CR>g@
|
nnoremap <buffer><silent> + :set operatorfunc=AddListSymbol<CR>g@
|
||||||
xnoremap <buffer><silent> + :<C-U> call AddListSymbol(visualmode(), 1)<CR>
|
xnoremap <buffer><silent> + :<C-U> call AddListSymbol(visualmode(), 1)<CR>
|
||||||
|
|
||||||
@ -32,11 +33,11 @@ function! AddListSymbol(type, ...) abort
|
|||||||
for line in range(line_start, line_end)
|
for line in range(line_start, line_end)
|
||||||
let text = getline(line)
|
let text = getline(line)
|
||||||
|
|
||||||
let end = matchend(text, '^\s*')
|
let l:end = matchend(text, '^\s*')
|
||||||
if end == 0
|
if l:end == 0
|
||||||
let new_text = '+ ' . text
|
let new_text = '+ ' . text
|
||||||
else
|
else
|
||||||
let new_text = text[0:end-1] . ' + ' . text[end:]
|
let new_text = text[0 : l:end-1] . ' + ' . text[l:end :]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call setline(line, new_text)
|
call setline(line, new_text)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user