Markdown headers in vim

One nice feature that TextMate’s Markdown bundle has is being able to easily mark a header by going to the line after a header, typing # followed by , and having TextMate insert #’s until the last # lines up with the last character of the title.

This Will Be My Header
#<Tab>

Turns into this:

This Will Be My Header
######################
Here’s how to do this in Vim:

:t.|s/./#/g

Don’t know what those commands do? Find out with Vim’s built-in help (:h, use it!).

In nutshell, :t. copies the text of the current line to to the line below the line given, and then s/./#/g substitutes any character on that line with a ‘#’.


Follow me on Twitter to keep up with what I’ve learned building my personal finance tool, Stash.

Subscribe to my mailing list to learn more about technology and business.

Your email will never be shared with anyone else.

Read more posts …
Written: November 18th, 2011
Categories: vim, markdown