Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gq wrapping is still broken #390

Open
dylan-chong opened this issue Oct 8, 2018 · 3 comments
Open

gq wrapping is still broken #390

dylan-chong opened this issue Oct 8, 2018 · 3 comments

Comments

@dylan-chong
Copy link

Even with #375 merged, and using let g:vim_markdown_auto_insert_bullets = 0, the problem occurs below. (By the way, let g:vim_markdown_auto_insert_bullets = 0 should be the default behaviour, and possibly even shouldn't be an option because gq would be broken if it is not set or is set to 1)

- A very very long sentence with lots of words and it is doing stuff like not
  nothing but it is wrapping.
    - A very very long sentence with lots of words and it is doing stuff like not
      nothing but it is wrapping.
    - A very very long sentence with lots of words and it is doing stuff like not
      nothing but it is wrapping.
- A very very long sentence with lots of words and it is doing stuff like not
  nothing but it is wrapping.

gets converted to (using gqap):

- A very very long sentence with lots of words and it is doing stuff like not
  nothing but it is wrapping. - A very very long sentence with lots of words
  and it is doing stuff like not nothing but it is wrapping. - A very very long
  sentence with lots of words and it is doing stuff like not nothing but it is
  wrapping.
- A very very long sentence with lots of words and it is doing stuff like not
  nothing but it is wrapping.

So the bullet points that are indented get screwed up.

@lemontheme 's comment is the solution #232 (comment) but it is ugly having to copy paste something into my vim rc file. It is also annoying for anyone who uses gq and does not know of this issue

@cunha
Copy link

cunha commented Dec 28, 2018

I just started using vim-markdown and struggled with getting gq indentation working. I fixed it by setting comments=fb:>,fb:*,fb:+,fb:- (the default does not include f, which I do not understand):

From :help format-comments:

  f	Only the first line has the comment string.  Do not repeat comment on
	the next line, but preserve indentation (e.g., a bullet-list).

@arkku
Copy link

arkku commented Jan 26, 2020

Instead of making the lists comments, make them, well, lists:

let g:vim_markdown_auto_insert_bullets=0
let g:vim_markdown_new_list_item_indent=0
au FileType markdown setlocal formatlistpat=^\\s*\\d\\+[.\)]\\s\\+\\\|^\\s*[*+~-]\\s\\+\\\|^\\(\\\|[*#]\\)\\[^[^\\]]\\+\\]:\\s | setlocal comments=n:> | setlocal formatoptions+=cn

@matochondrion
Copy link

matochondrion commented Jul 30, 2020

I just started using vim-markdown and struggled with getting gq indentation working. I fixed it by setting comments=fb:>,fb:*,fb:+,fb:- (the default does not include f, which I do not understand):

From :help format-comments:

  f	Only the first line has the comment string.  Do not repeat comment on
	the next line, but preserve indentation (e.g., a bullet-list).

I set this to only apply to markdown files to so as to not break commenting on other file types. Not 100% sure this is necessary.

  autocmd BufRead,BufNewFile *.md setlocal comments=fb:>,fb:*,fb:+,fb:-

serban added a commit to serban/dotfiles that referenced this issue Feb 6, 2022
plasticboy/vim-markdown `formatoptions`, `comments`, and `indentexpr`
lead to incorrect indentation and hard wrapping behavior as per:

* preservim/vim-markdown#232
  + Rewrapping a bullet point inserts new bullet points
* preservim/vim-markdown#390
  + gq wrapping is still broken

tpope/vim-markdown has the correct behavior. Compare the two
implementations:

* https://github.com/preservim/vim-markdown/blob/50d42082819cfa91745b6eff6e28ad5cbc8b27fa/indent/markdown.vim#L4
* https://github.com/tpope/vim-markdown/blob/891dff54a92b04cda36da7fbc6634831c3389d29/ftplugin/markdown.vim#L12

See also `formatlistpat` and explanations at:

* https://vimways.org/2018/formatting-lists-with-vim
* https://blog.siddharthkannan.in/2019/11/02/format-list-pat-and-vim

While I'm at it, introduce dkarter/bullets.vim to take my list game to
the next level.

Pro Tip: When switching back and forth between plasticboy/vim-markdown
and tpope/vim-markdown, use the following to keep vim-plug happy:

    Plug 'tpope/vim-markdown', {'as': 'tpope-markdown'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants