You could even teach Vim about a new extension of your own creation that acts Then use an autocmd inįiletype.vim to set the wrap for just one of the extensions autocmd bufreadpre *.mkd setlocal textwidth=0 One solution is to use a separate extension for the different flavors. The easiest solution to this is to just turn off hard-wrap when working on filesįor these systems / tools. ThisV is problematic if, like me, youĪdds that helpful newline you have an unexpected break in a weird place when it So, most places you use Markdown (like GitHub README.md files) will insert a Two invisible characters at the end of a line is not intuitive to new users. Two spaces “ ” to get a or hit return twice to start a new paragraph Not cause a newline to appear in the final HTML output. Spec single newline characters (hitting return) do In “pure” Markdown, as defined by its creator and the CommonMark It seems completely random which sites (or tools) are going to insert a for each newline and which ones won’t. Newline handling is… a pain in the butt for people who really love using Markdown.
Wish it could just…” and added a tweak, or twenty, to their “flavor” of Since then a lot of different sites and webapps have said “I The CommonMark spec ) was designed with very limitedĬapabilities. Yes, it's weird that with autoindent off, Vim will autoindent the first line but not subsequent ones. If you want it on by default for all file types (not a bad default) you can add set autoindent to your ~/.vimrc.Īlternately you can set it just for markdown files. To correct this you’ll want to make sure that autoindent is turned on. Unfortunately, it has issues when you have bullet items longer than 2 lines if you don’t have autoindent turned on. Without that auto-indentation the lines would be much harder to read. As you can see it also works with sub-lists. For example: the list below has lines that wrap, but were indented automatically by Vim. In addition to a stylized preview, Vim will also help you make lists. I’ll leave it as an exercise for the reader to figure out what conceallevel=1 This also works when the line is part of a visual selection. When you put your cursor in a line with concealed characters the concealed characters are revealed.
You’d think this would cause problems for editing because the formatting characters are literally not there, but don’t worry. Here’s an example of the same text as in the first image, but after running :set conceallevel=2 If you prefer a more streamlined look, where your text isn’t cluttered by formatting characters for your bold and italic text you can “conceal them. Note that italics are handled differently in terminal Vim, because most terminals can’t display italics. Especially when you consider the inherent limitations of an editor that must be able to run within the terminal. Vim does a pretty good job of giving you a stylized preview of your Markdown.