7

I'm writing a basic README.md for documentation at my company.

I'd like to wrap each line of text at 80 characters, but I really don't know how. At present, it just extends all the way to the right of the page.

Do I need a table?

I'd ideally not like to modify each separate line. Is there any way to wrap an entire paragraph?

1
  • FYI many devices are less than 80 characters wide - phones may be less, even Unix is often 72 characters wide. Is there a specific need to add carriage returns after every 80 characters for every reader, rather than just set whatever you preferred width is during editing? Jan 5, 2018 at 12:04
4

According to this, you just need to type a double space followed by a carriage return. Most modern text editors will let you know what column you're on.

The quickest, easiest way to do this is use Notepad++. Select the text you wish to wrap and use the menu option TextFX -> TextFX Edit -> ReWrap Text to (Clipboard or 72) Width.

7
  • I'm still not clear. If I try pressing space twice and then "Enter" after a line, there seems to be no effect.
    – user5732979
    Apr 19, 2016 at 20:51
  • There is no special formatting for hard-wrapped text in markdown. You just double space and hit enter at 80 characters.
    – TriskalJM
    Apr 19, 2016 at 20:52
  • This doesn't seem to do anything for me. I feel like I'm missing something obvious. line of text space space enter leaves it the same.
    – user5732979
    Apr 19, 2016 at 20:54
  • Modified the question to ask for solutions at the paragraph instead of line level. Adding an explicit <br /> tag works, but if I ever want to add anything, I have to modify everything. Is there any way around that?
    – user5732979
    Apr 19, 2016 at 20:58
  • Interesting. This only works when there's not tags. But the moment I try using <h1> somewhere, it stops working. Any clue why?
    – user5732979
    Apr 19, 2016 at 21:12
1

When you do want to insert a
break tag using Markdown, you end a line with two or more spaces, then type return. -Daring Fireball

So, you can look at your editor's display and when you are at column 80, type two spaces, and then type return.

1
  • 1
    Modified the question to ask for solutions at the paragraph instead of line level. Adding an explicit <br /> tag works, but if I ever want to add anything, I have to modify everything. Is there any way around that?
    – user5732979
    Apr 19, 2016 at 20:58
-1

A simple hack using clang-format:

Install clang-format(if not already installed)

sudo apt-get install clang-format

Generate clang-format file(if not already present)

clang-format -style=llvm -dump-config > .clang-format

Copy contents of .md file and paste it in a new file, save this newly created file with extension .cpp. Mark pasted content of .md file as a C++ comment by encapsulating it with /* and */

Use created clang-format file as,

clang-format -i foo.cpp

where foo is the name of saved C++ file.

You can now uncomment contents of original .md file and use it.

Note:

This works due to the following property of clang-format file

ColumnLimit:     80

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy