Skip to content
This repository was archived by the owner on Mar 9, 2020. It is now read-only.

kaymmm/vim-markdownfootnotes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VimFootnotes for Markdown with automatic footnote counter

This fork is derived from a combination of this fork and this pull request of the vim-pandoc vim-markdownfootnotes, which in turn is a slight tweak of the venerable vimfootnotes, for use with extended markdown.

Unlike derdennis's fork, this version doesn't use the fn notation, but keeps the restore functionality. It also changes the <leader>f insert mode mapping to [] to avoid annoying typing delays and accidental insertions of footnotes. Finally, it gets rid of the keyboard mappings to return from a footnote since it's easy enough to :q out of the minibuffer.

The remainder of this README is copied from derdennis's fork.

=====

The footnote number gets determined by an automatic counter whenever a new footnote gets inserted. This renders the commands FootnoteNumber, FootnoteNumberRestore and FootnoteUndo essentially useless...

The counter works with the default arabic numerals and all other settings provided by b:vimfootnotetype.

I did not write the counter myself. I found the code for the counting of HTML footnotes in this post by Nick Coleman, adjusted it slightly to work with Markdown footnotes and cobbled it into the original plugin from David Sanson.

All praise belong to these two fine gentlemen, all errors are mine.

The script defines two mappings,

<Leader>f    Insert new footnote 
<Leader>r    Return from footnote

To insert a footnote, type <Leader>f. A footnote mark will be inserted after the cursor. A matching footnote mark will be inserted at the end of the file. A new buffer will open in a split window at the bottom of your screen, ready to edit the new footnote. When you are done, type <Leader>r to close the split and return to the main text.

Screenshot

Sample text produced by the awesome Samuel L. Ipsum.

Installation

Drop markdownfootnotes.vim in your plugin directory.

Or use Pathogen.

Settings

By default, footnote ids are arabic numerals. You can change this by setting b:vimfootnotetype:

  • arabic: 1, 2, 3...
  • alpha: a, b, c, aa, bb..., zz, a...
  • Alpha: A, B, C, AA, BB..., ZZ, A...
  • roman: i, ii, iii... (displayed properly up to 89)
  • Roman: I, II, III...
  • star: *, **, ***...

Commands

AddVimFootnote : inserts footnotemark at cursor location, inserts footnotemark on new line at end of file, opens a split window all ready for you to enter in the footnote.

ReturnFromFootnote : closes the split window and returns to the text in proper place.

These are mapped to <Leader>f and <Leader>r respectively.

FootnoteNumber : Change the current footnote number (one obligatory argument) :FootnoteNumber 5

FootnoteNumberRestore : Restore old footnote number

FootnoteUndo : Decrease footnote counter by 1

FootnoteMeta [<footnotetype>] : Change type of the footnotes and restart counter (1, a, A, i, I, *)

The <footnotetype> argument is optional. If omitted, and your previous footnote type was not arabic, the new type will be arabic; if it was arabic, the new type will be alpha. If the new type is the same as the previous type, then the counter will not be restarted.

FootnoteRestore : Restore previous footnote type and counter.

About

Insert Extended Markdown Footnotes in Vim

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Vim Script 100.0%