digitalcourage.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Diese Instanz wird betrieben von Digitalcourage e.V. für die Allgemeinheit. Damit wir das nachhaltig tun können, erheben wir einen jährlichen Vorausbeitrag von 1€/Monat per SEPA-Lastschrifteinzug.

Server stats:

860
active users

Johannes Kastl

Edit: Solved, see my answer in the thread! Thanks everyone, you are awesome!

Dear users,

I am trying to re-learn emacs after using for several years.

One thing that I really liked in vim is that I can "reformat" long lines in a file by marking the lines (VISUAL mode) and then hitting "gq". This kept the markdown format, e.g. lists are still lists, but the lines are wrapped at whatever I set as the maximum line length.

It seems I am missing the right search terms because I only find "M-q" aka fill-paragraph, but this does not respect e.g. markdown lists.

Does anyone have pointers or search terms for me?

Thanks for all the answers! I should have thought to check that markdown-mode is properly working. For some reason *.md files were not detected as markdown-mode files.

The reason I did not notice that it does not fully work is because I had set some things for *.md files in editorconfig, which were being respected.

Removed the package, installed again, now they are being detected and formatting long lines using M-q works! Hooray!

And I also added line to my emac configuration so *.changes files from RPMs are also set to markdown mode. Hooray again!

(Johannes goes and searches for "Chandler dancing" GIF...)

@nik Thanks Nik, I'll check that, I surely have the package installed.

@johanneskastl
Try to select something and run 'M-x fill-region' and see what happens.
I'm using OrgMode and 'M-q' works fine with lists.

@johanneskastl I am not by my computer, but perhaps M-C-q will do what you want.

Also be sure to be in the correct major mode, that is a markdown mode, otherwise Emacs will not know what the proper formatting of a paragraph.

As I remember, there is not a mardown mode i the main library but there are several addon packages (checkout packages-list-packages).

@mapcar Thanks, I forgot to mention that the markdown-mode package is installed. But it may not be used/detected properly, I'll double check.

@johanneskastl Emacs doesn't have a built-in Markdown mode, so you'll have to install one. See <jblevins.org/projects/markdown> for how to set up MELPA Stable and then install markdown-mode. In that mode, M-q fills lines without breaking the formatting.

jblevins.orgMarkdown Mode for EmacsA major mode for GNU Emacs for editing Markdown-formatted text files.

@jks Thanks for the confirmation. I forgot to mention that I have this package installed and have assumed it should do the trick. But maybe I borked my configuration and it is not detecting the file as markdown.

@johanneskastl Check if your modeline has the word Markdown in parentheses, possibly followed by other indicators.

If not, the mode is not active for the current file. In that case, try M-x markdown-mode RET. If it helps, the problem is in your auto-mode-alist. If not, the package is not properly installed, and you may want to try removing and reinstalling it.

If you *are* using Markdown mode and M-q messes up the formatting, then it might be an overridden keybinding.

@jks See my reply in the thread, apparently I messed up the package and it was not working properly...

@johanneskastl

I took a quick look at the #markdown mode documentation. But I didn't see anything for width formatting of lists. Don't they render correctly anyway?

I always use !!fmt but that only works on the current line.

That doesn't mean it's not there, but that would be the place to look first. That and the #Emacs wiki.

I never write markdown anymore. I write in #org.

@Zenie Thanks Zenie, orgmode is on my list. First I need to get my vim workflows working in emacs... :-)

I also found no trace of formatting in the markdown package documentation, but according to other answers it should work.

@johanneskastl
That's good to know at least. I wonder why it doesn't? Always the question.

@johanneskastl i don't know vim, but that seems like the right function. in org mode it'll wrap lists too iirc.