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

Keybinding for copying selections on matching substrings vertically #1116

Closed
wants to merge 3 commits into from
Closed

Keybinding for copying selections on matching substrings vertically #1116

wants to merge 3 commits into from

Conversation

rouanth
Copy link

@rouanth rouanth commented Jan 9, 2017

A new keybinding, ^, which allows for selecting substrings that are directly above or below the currently selected one if their contents match that of the original selection.

For example:

/// Long
/// comment
/// ...
fn main() { }

If the cursor is located at the beginning of the snippet, pressing ^ causes the / at the beginning of each of the first three lines to be selected.

@danr
Copy link
Contributor

danr commented Jan 9, 2017

This is an interesting keybinding (and I now understand what you meant with it)!
It does not need to be implemented in the C++ kakoune source though, it should be possible to get it going with some scripting.

This keybinding allows to copy the current selections vertically to the
preceding and following lines if the selections that would result have
the same contents as the source selection. This fixes #1115
Unit test checks that kakoune copies selections to matching substrings
that are located directly above and below.
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
@lenormf
Copy link
Contributor

lenormf commented Jan 10, 2017

As said previously, I don't think adding this to the primitives makes much sense, it sounds too specific, better keep it as a mapping in your user configuration.

@mawww
Copy link
Owner

mawww commented Jan 10, 2017

This is an interesting binding, but I am not convinced it has wide enough applications to warrant being a built-in, I think it should be doable through a mapping.

Do you have examples of editing problems that are cumbersome to do without that binding ? It seems in many cases C and <a-k> can be used.

@rouanth
Copy link
Author

rouanth commented Jan 10, 2017

I've provided some use cases in the issue which this request closes: #1115. In general, I often encounter text which is distinguished by a vertical structure but isn't on a separate paragraph and doesn't have a fixed number of lines. For these cases, both C and <a-k> can be used perfectly well when editing manually; however, when doing automation with macros, C needs to know the number of lines, and the regular expressions required to do it with <a-k> in general case and without relying on its interactivity are often unnecessarily complex.

I will try to write a script that implements the keybinding, but I must warn that it can take very long for me to get to it. I guess the pull request can be rejected, but I'll leave the issue open if it's fine with you.

Thank you all for your analysis!

@rouanth rouanth closed this Jan 10, 2017
@alexherbo2
Copy link
Contributor

https://github.com/occivink/kakoune-vertical-selection

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

Successfully merging this pull request may close these issues.

5 participants