I have a problem with breaking long line in markdown
file. Given the following line
* "fo" : You can use the 'formatoptions' option to influence how Vim formats text. 'formatoptions' is a string that can contain any of the letters below. The default setting is "tcq".
runing gq$
will end up with
* "fo" : You can use the 'formatoptions' option to influence how Vim formats
* text. 'formatoptions' is a string that can contain any of the letters below.
* The default setting is "tcq".
where the two new *
below are definitely extra and erroneous. Ideally, I'd like to set my option or remap my gq$
to produce the following formatted text
* "fo" : You can use the 'formatoptions' option to influence how Vim formats
text. 'formatoptions' is a string that can contain any of the letters
below. The default setting is "tcq".
If that is not easy to do, at least the two extra *
should be gone and produces
* "fo" : You can use the 'formatoptions' option to influence how Vim formats
text. 'formatoptions' is a string that can contain any of the letters below.
The default setting is "tcq".
How can I remap to achieve the desired formatted text?
By the way, is there a quick way to gq
pasted text?
:set comments?
return for you? Withfb:*
as one of the entries, I get the result without the repeated*
s... Do you have any of:set formatexpr? formatprg?
set? (That might interfere with what this command does...):set comments?
gives mecomments=b:>,b:*,b:+,b:-
, while bothformatexpr
andformatprg
are empty. I'm thinking of a mapnnoremap gQ ^vyvr gq$<C-o>Plx
but with some problems. The<C-o>
part (and after) fails.:verbose set comments?
I havecomments=fb:*,fb:-,fb:+,n:>
andLast set from
$VIMRUNTIME/ftplugin/markdown.vim`. I'm on Vim 8.2.717. Maybe you need a newer vim-markdown?comments=b:>,b:*,b:+,b:-
andLast set from ~/.vim/plugged/vim-markdown/indent/markdown.vim line 15
. I will try that later. Thanks! By the way, my desired format should be achieved by (at least everything is working correctly when typing the mapped keys literally)nnoremap <silent> gQ :exe "normal ^vt:yvt:r\<Space>i\<Space>\<Space>\<Esc>gq$g'.0vt:P"<Bar><CR>
but the ` \<Esc>` key is not working here, is there a quick fix?