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: Support jumping to next section with ]] & [[ #146

Closed
m-fonseca opened this issue Apr 13, 2021 · 5 comments
Closed

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

m-fonseca opened this issue Apr 13, 2021 · 5 comments
Assignees
Labels
feature:request Requesting new and additions to existing features.

Comments

@m-fonseca
Copy link

m-fonseca commented Apr 13, 2021

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!

@SidOfc
Copy link
Owner

SidOfc commented Apr 14, 2021

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.

@m-fonseca
Copy link
Author

m-fonseca commented Apr 14, 2021

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!

@SidOfc
Copy link
Owner

SidOfc commented Apr 14, 2021

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. 👍

@SidOfc SidOfc self-assigned this Apr 14, 2021
@SidOfc SidOfc added the feature:request Requesting new and additions to existing features. label Apr 14, 2021
@SidOfc
Copy link
Owner

SidOfc commented May 1, 2021

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 👍

@SidOfc SidOfc closed this as completed May 1, 2021
@m-fonseca
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:request Requesting new and additions to existing features.
Projects
None yet
Development

No branches or pull requests

2 participants