Folding Markdown in Vim without a plugin
Vim offers folding, which is a great option when editing a longer text file.
Although there is a plugin available for Markdown folding, Vim can fold Markdown without it.
All it takes are a few lines in your .vimrc. Below, we start with just two lines to get it working.
After this, we add some more lines to get folding back after installing the fabulous Vimwiki plugin and to make it nice and convenient.
With just a few lines in your .vimrc you can use folding in Markdown files.
filetype plugin on let g:markdown_folding=1
Open a Markdown file, set filetype=markdown and you can start using folding.
The installation of Vimwiki influences folding of Markdown files.
To enable folding of Markdown files after installing Vimwiki, add the following line to your .vimrc:
let g:vimwiki_global_ext = 0
Now you can again use folding in Markdown files.
Pretty folding in your terminal
Vim is configured for a white on black terminal with the line
This is for syntax coloring usually good. Folds are shown with a colored background, which iMHO is not that great.
The following line removes the colored background:
highlight Folded term=standout ctermfg=14 ctermbg=0
Easy toggle of fold with the space bar
The key-binding to toggle a fold is 'za'. This is a very useful function.
It can be bound to the space bar, for even more convenience.
nnoremap <space> za vnoremap <space> za