Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider refactoring default binding system #17

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@ Here is some text.[^1]

[^1]: Here is a note.
~~~
)

The footnote number gets determined by an automatic counter whenever a new
footnote gets inserted. The counter works with the default arabic numerals
and all other settings provided by `b:vimfootnotetype`. The automatic counter
code is based on the code for the counting of HTML footnotes in [this post by
Nick Coleman][3], adjusted slightly to work with Markdown footnotes.

The script defines two mappings,
To insert a footnote, hit `<Leader>f` in normal mode or type `[]`. Then

~~~
<Leader>f Insert new footnote
<Leader>r Return from footnote
~~~
- A footnote mark will be inserted after the cursor,
- A matching footnote mark will be inserted at the end of the file, and
- a split window at the bottom will open, ready to edit the new 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.
When done, type `ZZ` to close the split and return to the main text.

![Screenshot][5]

Expand Down
12 changes: 7 additions & 5 deletions doc/markdownfootnotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ markdown-footnotes, add footnotes in markdown *markdown-footnotes* *footnotes*
0. Introduction ~
*markdown-footnotes-intro*

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.
To insert a footnote, hit `<Leader>f` in normal mode or type `[]`. Then

- A footnote mark will be inserted after the cursor,
- A matching footnote mark will be inserted at the end of the file, and
- a split window at the bottom will open, ready to edit the new footnote.

When done, type `ZZ` to close the split and return to the main text.

===========================================================================
1. Commands ~
Expand Down
12 changes: 1 addition & 11 deletions ftplugin/markdown/markdownfootnotes.vim
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,15 @@ endif

" Mappings
if !hasmapto('<Plug>AddVimFootnote', 'i') && mapcheck('<Leader>f', 'i') is# ''
imap <buffer> <Leader>f <Plug>AddVimFootnote
inoreabbrev <buffer> [] <c-o>:exe "normal \<Plug>AddVimFootnote"<cr>
endif
if !hasmapto('<Plug>AddVimFootnote', 'n') && mapcheck('<Leader>f', 'n') is# ""
nmap <buffer> <Leader>f <Plug>AddVimFootnote
endif

if !hasmapto('<Plug>ReturnFromFootnote', 'i') && mapcheck('<Leader>r', 'i') is# ''
imap <buffer> <Leader>r <Plug>ReturnFromFootnote
endif
if !hasmapto('<Plug>ReturnFromFootnote', 'n') && mapcheck('<Leader>r', 'n') is# ''
nmap <buffer> <Leader>r <Plug>ReturnFromFootnote
endif

nnoremap <buffer> <Plug>AddVimFootnote :<c-u>call markdownfootnotes#VimFootnotes('a')<CR>
inoremap <buffer> <Plug>AddVimFootnote <C-O>:<c-u>call markdownfootnotes#VimFootnotes('a')<CR>

inoremap <Plug>ReturnFromFootnote <C-O>:<c-u>q<CR><Right>
nnoremap <Plug>ReturnFromFootnote :<c-u>q<CR><Right>

" :Footnote commands
command! -buffer -nargs=1 FootnoteNumber call markdownfootnotes#VimFootnoteNumber(<q-args>)
command! -buffer -nargs=0 FootnoteNumberRestore call markdownfootnotes#VimFootnoteNumberRestore()
Expand Down