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

Reverse search <a-/> orthoganality #3925

Closed
vbauerster opened this issue Dec 2, 2020 · 5 comments
Closed

Reverse search <a-/> orthoganality #3925

vbauerster opened this issue Dec 2, 2020 · 5 comments

Comments

@vbauerster
Copy link
Contributor

While regular searching with / directions of n and <a-n> are natural and orthogonal i.e. former jumps down and latter jumps up. However while reverse searching with <a-/> directions of n and <a-n> are the same as in regular search. I expected that in reverse search n and <a-n> would reverse their directions respectively, but this is not the case. The reverse part of <a-/> is only in its initial jump and afterwards I still have to hold alt key to keep reverse direction, which in my opinion is not so orthogonal.

@lenormf
Copy link
Contributor

lenormf commented Dec 2, 2020

Setting a side effect on primitives predicated on which one was used previously doesn't sound great, it's not predictable.

One problem I can see would occur upon a user using a-/, then *. I think the user would expect that subsequently hitting n would select the next (downward) match, but since * modifies the search register / directly (and shouldn't assume that the user's intent is to search downward), hitting n would select the previous (upward) match.

@lenormf
Copy link
Contributor

lenormf commented Dec 3, 2020

I think this behaviour could make for a good plugin, or at least a good snippet for the users' configuration. Here's my quick implementation of it:

define-command -hidden -params 1 search_direction %{ evaluate-commands %sh{
    case "$1" in
        up) echo "
            map global normal n <a-n>
            map global normal <a-n> n
            exec <a-/>
        ";;

        down) echo "
            map global normal n n
            map global normal <a-n> <a-n>
            exec /
        ";;
    esac
} }

map global normal <a-/> ': search_direction up<ret>'
map global normal / ': search_direction down<ret>'

If you do decide to adapt the above code and use it in your user configuration, could you please document it in the wiki?

@vbauerster
Copy link
Contributor Author

Nice solution!

could you please document it in the wiki?

Yes of course, I think placing it under Editing paragraph. Is it ok?

@lenormf
Copy link
Contributor

lenormf commented Dec 3, 2020

Sounds good, I rarely care about what's on the wiki, so feel free to create pages as you see fit.

@vbauerster
Copy link
Contributor Author

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