A vim script to mark folds on Markdown headers by default
You can write a script for vim to mark folds on Markdown headers automatically, by default, so you don’t have to manually set markers.
To do so add the following script1 to your
" Mark folds on Markdown headers function! MarkdownFolds() let thisline = getline(v:lnum) if match(thisline, '^##') >= 0 return ">2" elseif match(thisline, '^#') >= 0 return ">1" else return "=" endif endfunction setlocal foldmethod=expr setlocal foldexpr=MarkdownFolds()
You should find the
.vimrc file under the path
Reload your buffer:
:e, short for
Now folds should be marked. You can use
zm and other fold commands without having to add markers manually.
:h fold in vim to see all the fold commands.
I do self-funded research and I'm writing a book.
> What's the book about?
About technologies and epistemology.
Meaning, technologies can foster agency. No doubt. But I am also asking:
Can technologies make us blind?
I posted a summary of the prologue on the homepage: https://yctct.com/