Effectively Editing Markdown Files in Vim

Writing markdown is not like writing code, or even HTML at times. Markdown is almost exclusively plain English and has very few tags and very little syntax, unlike HTML and all other programming languages. This puts Markdown in a very strange place, since it cannot be edited effectively in a traditional word processor, and, it's structure makes it a poor fit for many text editors. I played around with many different editors, including Sublime, Atom, and even Visual Studio Code. The best fit was probably Atom, however, it's spell-checking is very inefficient to use, or at least, I never was able to find a quick way to make corrections. This is perfectly fine, of course, Atom is meant as a text editor for code, seemingly JavaScript, where spelling is not important at all. But, I have the English-language ability of a paper bag, and essentially require a spell-checker to not make numerous errors without fail.

Eventually, I ended up back at my roots, so to speak, using Vim. However, Vim is also completely awful for Markdown by default as well, however, I know how to configure it and there is a very robust community which has fixed the vast majority of issues I encountered.

Vimrc Changes

By default, Vim does not recognize Markdown files as a filetype. This is fixed with a script later, but it is also entirely possible to fix without the script by simply adding the following to your .vimrc:

filetype on
filetype plugin on
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown

Now markdown files can be treated like any other file type. Personally, I added the following to make my markdown edition experience more pleasurable:

"" Markdown
au FileType markdown set spell
au FileType markdown set autoindent
au FileType markdown set smartindent
au FileType markdown set list
au FileType markdown set lcs=tab:>-
au FileType markdown set textwidth=115

There's nothing too fancy here. spell is simply enabled because I fail tremendously at the English language. autoindent and smartindent are both enabled to make editing lists require less liberal use of the tab key. list and lcs=tab:>- work together to display the indentation levels when they are present. I find this makes it much easier to determine which level I'm writing at in long chains of lists, which, often happens while I'm taking notes. Finally, textwidth=115 is something I'm still playing with. It forces Vim to start a new line once it reaches 115 characters which is useful because it is very painful to edit extremely long lines. However, this value will mostly likely change because 115 is a bit too small on a 1080p monitor, and, too wide for a split view on my laptop's puny 1600x900 monitor.

Markdown.vim

Markdown.vim is a script which adds proper detection of markdown filetypes, adds syntax highlighting support, and, includes some features which some may find useful. It works pretty well out of the box, however, a few small changes were required for me personally. The section in my .vimrc is as follows:

"" Markdown.vim
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0

The only changes above disable folding when a file is opened, which I find particularly obnoxious, and disables concealing. Concealing, in this context, hides the contents of a link while editing to save space. I actually haven't used Markdown.vim too much, so, I will do an article in the future outlining some more advanced features and customizations that I will eventually learn to use and decide on.

blogroll

social