mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
[feat] add mapping to add hard linebreak for Markdown
This commit is contained in:
parent
36bdde7fc9
commit
9dbeb67de5
@ -45,3 +45,25 @@ function! AddListSymbol(type, ...) abort
|
|||||||
call setline(line, new_text)
|
call setline(line, new_text)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Add hard line breaks for Markdown
|
||||||
|
nnoremap <buffer><silent> \ :set operatorfunc=AddLineBreak<CR>g@
|
||||||
|
xnoremap <buffer><silent> \ :<C-U> call AddLineBreak(visualmode(), 1)<CR>
|
||||||
|
|
||||||
|
function! AddLineBreak(type, ...) abort
|
||||||
|
if a:0
|
||||||
|
let line_start = line("'<")
|
||||||
|
let line_end = line("'>")
|
||||||
|
else
|
||||||
|
let line_start = line("'[")
|
||||||
|
let line_end = line("']")
|
||||||
|
endif
|
||||||
|
|
||||||
|
for line in range(line_start, line_end)
|
||||||
|
let text = getline(line)
|
||||||
|
" add backslash to each line
|
||||||
|
let new_text = text . "\\"
|
||||||
|
|
||||||
|
call setline(line, new_text)
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user