• Stars
    star
    248
  • Rank 163,560 (Top 4 %)
  • Language
    Vim Script
  • Created about 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fold markdown documents by section.

[ Looking for new maintainer see note at end. ]

This plugin enables folding by section headings in markdown documents.

Features

This plugin adds the ability to fold the following markdown elements:

  • Headings and everything under them
  • Fenced code blocks

example screenshot of folding functionality

Usage

By default this plugin will use "Stacked" folding which looks like this when everything is folded.

  1 ##    Topmost heading                         [3 lines]---------------------------
  5 ###   Second level heading                    [3 lines]---------------------------
  9 ####  Third level heading                     [3 lines]---------------------------
 13 ####  Another third level heading             [2 lines]---------------------------

You can use "Nested" folding, where folding the "Topmost heading" will also nest all the deeper sections under it.

  1 ##    Topmost heading                         [14 lines]--------------------------

To toggle between the two folding styles use :FoldToggle

If you'd like to have it default to "Nested" folding add this to your ~/.vim/filetype.vim

autocmd FileType markdown set foldexpr=NestedMarkdownFolds()

Installation

After installing markdown-folding using a Vim package manager ( vim-plug, pathogen, Vundle, or Vim 8's native plugin system ). You will need to add the following lines to your ~/.vimrc file or ~/.config/nvim/init.vim for NeoVim:

    set nocompatible
    if has("autocmd")
      filetype plugin indent on
    endif

The markdown-folding plugin provides nothing more than a foldexpr for markdown files. If you want syntax highlighting and other niceties, then go and get tpope's vim-markdown plugin.

Troubleshooting

First, Vim must recognize the file you are in as a Markdown file. set filetype? should return filetype=markdown. If it doesn't you may want to tweak your filetype.vim to make sure it knows to associate your current file extension with Markdown. In the short term you can :set filetype=markdown

There are a variety of ways Vim can be instructed to "fold" things. When you add a plugin to support a new language / format the plugin will tell Vim "Hey here's the method to use for figuring out the start and end of a fold with this language". This plugin uses a foldmethod of expr. Running :set foldmethod? should return foldmethod=expr. If you see something else then you've likely got some other Vim configuration overriding the setting in the plugin. If, after running :set foldmethod=expr, things still aren't working, then something is most likely amiss in your ~/.vimrc (or ~/.config/nvim/init.vim if you use NeoVim).

Contributing

PRs are always a welcome thing, but it should be noted that the current intent is to keep this plugin pretty focused on folding Markdown.

All new PRs should include tests. If you're fixing a bug please add a test to make sure it never comes back. If you're adding a new feature please add tests to make sure we never break it with future changes.

The tests are currently all contained in t/folding.vim

Running Tests

The test setup requires Ruby. For those unfamiliar with Ruby development you'll want to cd into the vim-markdown-folding directory and run the following commands in the terminal.

Install bundler if you don't have it already.

gem install bundler

Tell bundler to install the required dependencies

bundle install

Tell bundler to run the tests

bundle exec rake test

The end of the output should look something like this

t/folding.vim .. ok
All tests successful.
Files=1, Tests=41,  1 wallclock secs ( 0.03 usr  0.01 sys +  0.57 cusr  0.12 csys =  0.73 CPU)
Result: PASS

License

Created by Drew Neil. Copyright Drew Niel and all the contributors. Distributed under the same terms as Vim itself. See :help license.

With community improvements by:

Maintained by masukomi

Looking for New Maintainer

This works fine, but there are improvements that can be made, and PRs that need addressing. If you've familiar with vim-script and have some vim-script stuff you can point at, gimme a holler @[email protected] on mastodon or @masukomi on twitter. I use Doom Emacs these days so vim-script isn't where my head is.

More Repositories

1

kudos

An example of Svbtle style kudos
CSS
412
star
2

arc90-readability

A copy of the original Arc90 repo with links to many of the current ports.
PHP
214
star
3

JekyllMail

JekyllMail enables you to post to your Jekyll / Octopress powered blog by email.
Ruby
119
star
4

aspirin

Aspirin is an embeddable send-only SMTP server.
Java
90
star
5

mobtvse

Working towards being the worlds best Markdown blogging app...
JavaScript
45
star
6

private_comments

a tool for managing private comments on, but not in, your files
Scheme
44
star
7

hey

Hey allows you to track your interruptions as they occur.
JavaScript
31
star
8

oho

oho: converts colorful terminal output to html
Crystal
30
star
9

jsonpath-perl

Perl port of JSONPath
Perl
23
star
10

git_accessories

assorted little helper scripts for git
Shell
22
star
11

changelog_manager

A tool to let a team add CHANGELOG entries without constant conflicts.
Crystal
19
star
12

omniauth-dwolla

Dwolla OAuth2 Strategy for OmniAuth 1.0.
Ruby
17
star
13

private-comments-mode

Emacs Lisp
15
star
14

cleandiff

CleanDiff is a better diffing tool, that's easier on your brain.
Shell
11
star
15

hey_3

Hey! An Interruption and Time Tracking Command line app.
Raku
11
star
16

passbook2

Ruby Gem to generate Apple Passbook files.
Ruby
10
star
17

git-status-report

a git tool for creating weekly status reports
Ruby
10
star
18

masuconfigs

masukomi's collection of configuration files, and common scripts.
Vim Script
7
star
19

rtest

An RSpec wrapper to cut down on noise and simplify rerunning tests.
Ruby
6
star
20

fenestro

ingests HTML from the command line and renders it in helpful windows
Swift
5
star
21

backup_brain

A self-hosted bookmarks manager with "Reader View" style link archiving.
Ruby
4
star
22

tampermonkey_scripts

JavaScript
4
star
23

got

A simple shell script that makes it trivial to see if a process is running and give you the details.
4
star
24

dwdiff-annotated

an annotated version of the dwdiff source code
C
3
star
25

vim_private_comments

a vim plugin for private comments
Vim Script
3
star
26

sentence_options

A command line options parser for sentence-like human interfaces to your apps.
Crystal
3
star
27

Definitely

An implementation of the Maybe Monad for Raku
Raku
3
star
28

readable_url

Simplify URL content with Readability & optionally convert to Markdown.
Rust
3
star
29

Terminal-Graphing-BarChart

Raku Library for generating Bar Charts for the Command Line
Raku
3
star
30

ob-raku

Raku support for org-babel
Emacs Lisp
3
star
31

passy

A password generator for Ubiquity
JavaScript
2
star
32

gpup

Makes it easy to push to the upstream git branch, and eliminates possibility of force pushing to the wrong place.
Shell
2
star
33

crystal_fmt

produces text tables from a grid of strings
Crystal
2
star
34

masubiquity

A collection of Ubiquity commands written by masukomi
JavaScript
2
star
35

html_encode_decode

A Vim plugin to encode and decode HTML entities
Vim Script
2
star
36

UUID-V4

Raku library to generate a random v4 UUID (Universally Unique IDentifier)
Raku
2
star
37

acl_plus_rbac

Rails plugin supporting Access Control Lists + Role Based Authorization
Ruby
2
star
38

mdcd

MarkDown Code Documentation (for Chicken Scheme)
Scheme
2
star
39

graceful_disasters

Source Documents for the Graceful Disasters Incident Management Process http://gracefuldisasters.com
2
star
40

git_branch_finder

A tool too help you find that branch you did that thing in.
Shell
1
star
41

postcircumfix-test

a test package demonstrating a potential bug in postcircumfix
Raku
1
star
42

crystal_cli_graph

a command line graph generator for crystal
Crystal
1
star
43

grouped_settings

A port of Alex Wayne's Settings plugin that adds support for groups of settings.
Ruby
1
star
44

hey_2

Hey, the interrupt tracker (version 2)
Crystal
1
star
45

jiok

Go
1
star
46

XDG-GuaranteedResources

Guarantees that a resource is present in the expected XDG Base Directory directory
Raku
1
star
47

gh-open-branch-pr

Easily find and open a GitHub PR from your current branch.
Ruby
1
star
48

Listicles

Adds convenience methods to Array
Raku
1
star
49

Prettier-Table

A simple Raku module to make it quick and easy to represent tabular data in visually appealing ASCII tables.
Raku
1
star
50

aha

Ansi HTML Adapter
C
1
star