SidOfc / mkdx

A vim plugin that adds some nice extra's for working with markdown documents

Home Page:https://www.vim.org/scripts/script.php?script_id=5620

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Support jumping to next section with ]] & [[

m-fonseca opened this issue · comments

Hello again!

The operators ]] & [[ are specifically made for jumping to the next and previous "sections". It would be nice to support this since every markdown heading is a distinct section. Right now ]] & [[ go to the bottom and top of the file respectively. I think I originally saw this in the pandoc vim plugin. Useful for getting around quickly through a large doc.

Thanks!

Looks like you are right, this is indeed part of vim-pandoc, found it in their docs here.

Although when checking Vim's native :h ]] doc it refers to :h section which refers to :h sections which seem to talk about something different entirely with regards to what a section is.

As for your use-case, I think for getting around a large document it'd be more effective to use mkkdx's PREFIXI mapping to open the headers in a quickfix window. Pressing enter on any header takes you there.

This only advantage mappings such as [[ and ]] have is if you know you need to be in the next section to just jump there immediately. If reading the quickfix list takes too long there's also an alternative method which supports fuzzy finding using the fzf plugin.

Granted you can specify a count to these jump mappings, but for large documents I doubt I'd remember how many counts away any specific header is.

Not going to close this yet as I'm interested to know if this suits your needs instead of adding additional functionality to mkdx.

I think your right about using PREFIXI for getting around large documents (I must have missed this, nice!). But it doesn't quiet allow one to brainlessly and quickly move to sections near the cursor (perhaps its onscreen or offscreen).

I guess in the end its all about two things (for me) speed and familiarity. One could just hold down j or } (and others) to get where they want but it can be faster/more efficient if you can move by section. I guess its ingrained behavior I expect when using vim, just like when I use ]] to jump from function to function in a .c file.

Its really nice to have key bindings that work similarly no matter what document/code you edit (same reason I wanted to map to ctrl-] in a previous comment if you recall).

Just a suggestion anyway. Its definitely your prerogative on what you want to go into the plugin!

I see, yes cognitive load will always be a bit higher when having to think about where you're going, I'm a person that usually knows where I want to make my edit so instead of the lighter cognitive load I prefer to get there in a more accurate manner. That aside there is definitely something that can be said about the opposite of that as well.

A "section" is quite an abstract concept as well and I agree that currently neither ]] or [[ provide much benefit to the user when editing a markdown file. With your additional feedback in mind I think it's worth implementing in mkdx including support for count prefixes.

I'm marking it as a feature request, not sure when I'll have the time or energy to implement it yet but I'll try to do this within reasonable time. 👍

Hi again @m-fonseca, I've implemented the feature you requested, if you update to the latest version everything should be working. It supports both # and ----- / ==== headers and also supports count so you can do 2]] for example. Let me know if you encounter any issues.

I'll close this as well, cheers for the feedback 👍

Just tried it out, works great! Thanks so much for this addition!