I write quite a lot of Markdown on a daily or weekly basis. From meeting notes to documentation — most of the stuff I write for work that’s not code starts in Markdown. I used to use Byword, but it’s another app to switch between. After the last MacBook refresh, there were a few apps I installed immediately and it has pretty much stayed that way.
I’ve been using Vim to edit Markdown, which is fine, but was missing some things. So, I went hunting for the proper vimscript to enable things like soft line-wrapping and spell check. Needless to say, you can do more than that.
One of the first things I found way Goyo. Goyo does “distraction-free writing in Vim” and does most of the work — disabling line numbers, vim-airline, soft-wrapping text at 80 characters, and centering it in the terminal window. You have to enable it with
:Goyo after you open Vim, but I always want it enabled when I’m editing Markdown, so I wrote some vimscript:
if &ft == 'markdown' && winnr('$') == 1
if winnr('$') < 2
autocmd BufNewFile,BufRead * call s:auto_goyo()
autocmd! User GoyoLeave nested call goyo_leave()
Next, I installed vim-markdown for syntax highlighting. Since most of my Markdown files have the
.md extension, I need to tell Vim to treat them as Markdown.
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
One of the vim-markdown features is to allow highlighting of other languages in code blocks:
And, finally, I enabled spell checking in
" Spell check
highlight clear SpellBad
highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline