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

Feature Request: Edit existing footnote in split screen #21

Open
dmoerner opened this issue Jun 29, 2020 · 2 comments
Open

Feature Request: Edit existing footnote in split screen #21

dmoerner opened this issue Jun 29, 2020 · 2 comments

Comments

@dmoerner
Copy link

dmoerner commented Jun 29, 2020

I find the editing in split screen functionality very useful, but vim-markdownfootnotes currently only supports creating new footnotes. It would be convenient to also be able to edit existing footnotes.

I use the following Vimscript to crudely implement this:

function! markdownfootnotes#VimEditFootnote()
    " Define search pattern for footnote definitions
    let l:footnotepattern = '\[\^\p\+\]'
    let l:flags = 'cW' 

    " Find the next footnote and align it for return             
    let [l:footnoteline, l:footnotepos] = searchpos(l:footnotepattern, l:flags)
    normal h 
    " Get the next footnote in a variable
    let l:text = getline(l:footnoteline)
    let l:footnotenumber = matchstr(l:text, l:footnotepattern)
                                                               
    " Do the split
    :below 4split                           
                                                                  
    " Move to the correct footnote and align at the start
    let l:temp = search('\V' . l:footnotenumber . ': ', 'W')
    normal f:2l  

endfunction

This is literally the first thing I've ever written in Vimscript, so I'm not submitting it as a pull request or anything at this stage. But this or similar functionality would be great to have in the plugin itself, and you're welcome to use this code as a start if it's helpful. It obviously currently doesn't have any error correction if we are at the end of the document.

@lyndhurst
Copy link

I agree with dmoerner, this would be a very helpful feature, a "delete" function that deletes the matching reference, or footnote, and renumbers could be very useful too imho.

@dmoerner
Copy link
Author

dmoerner commented Sep 6, 2021

@lyndhurst I have a little fork of this plugin, which implements editing existing footnotes, and also changes the behavior of adding footnotes to automatically insert the lowest footnote number possible: https://github.com/dmoerner/vim-markdownfootnotes

There's also a fork of my fork, which cleans up some of my code and has a few small changes: https://github.com/abstractednoah/vim-markdownfootnotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants