If you are using an auto-pairs-style plugin, it is most likely trying to delete the closing "; not finding one, it erroneously deletes further.
As mentioned in the comments, these plugins generally cause more headache than they’re worth (YMMV). Snippets provide a more flexible alternative (though the author has very little experience with them).
Add this to your after/ftplugin/c.vim or after/ftplugin/cpp.vim:
let &l:formatlistpat .= '\|^\s*-\s*'
It tell vim to recognize - as numbered list.
set them in vimrc is a mistake, this option is local to buffer. You can use :verbose setlocal formatlistpat to check if it's set properly.
// - foo foo foo foo foo foo foo foo foo foo foo foo foo ...
You can also get this behavior with this minimalist vimrc
au Filetype tex set comments=sO:%\ -,mO:%\ \ ,:%
au Filetype cpp set comments=sO:\/\/\ -,mO:\/\/\ \ ,:\/\/
When editing tex files you would get the following
% - foo foo foo foo foo foo foo foo foo foo ...
It would be really hard to do this for a real world markdown files with regards to all edge cases (tables, code blocks, list items, headers etc).
But for example given you can try following :h :global commands:
Join with :g/^\S.*\n\S/normal! vipJ
It searches for all "paragraphs" -- 2 consecutive lines that ...
As jecxgo points out, the problem is that the obvious solution of recording a macro that processes a single line and then applying that to the selection of lines with :normal fails because, when the lines are expanded, this messes with the other lines in the range.
jecxgo solves this by not expanding the lines within the macro but instead doing so in a ...