helix icon indicating copy to clipboard operation
helix copied to clipboard

Implement Kakoune's `A-S`

Open kirawi opened this issue 1 year ago • 8 comments

In Kakoune, it selects the first and last characters of each selection.

Where [] denotes a selection, [helix] becomes [h]eli[x]

It would look similar to https://github.com/helix-editor/helix/blob/87a720c3a13ccc7245f5b0befc008db5bd039032/helix-term/src/commands.rs#L1855-L1864 but use https://github.com/helix-editor/helix/blob/87a720c3a13ccc7245f5b0befc008db5bd039032/helix-core/src/selection.rs#L607-L614 instead

kirawi avatar Jan 28 '24 22:01 kirawi

Is anyone working on this one at the moment? I'd like to make my first contribution

scdailey avatar Jan 29 '24 13:01 scdailey

Nobody has announced that they're working on this, so it's probably fine?

kirawi avatar Jan 29 '24 14:01 kirawi

Cool! Ill give it a shot

scdailey avatar Jan 29 '24 14:01 scdailey

I'm not against this, just asking what is a usecase? The only situation I can see is something like selecting parentheses/brackets and delete them, but for that I can use existing keybinds.

woojiq avatar Jan 30 '24 11:01 woojiq

#9483

Just created a pull request for this one

scdailey avatar Jan 30 '24 15:01 scdailey

Did you have something specific in mind for this command @kirawi? I also wonder if we need a command for this given that we have surround tools builtin while Kakoune does not

the-mikedavis avatar Jan 30 '24 19:01 the-mikedavis

It was requested by https://matrix.to/#/!zMuVRxoqjyxyjSEBXc:matrix.org/$bFvOW3o-qWGL_cSdJWwK1wE86NXUz8LFq7rBJtO6VMA?via=matrix.org&via=mozilla.org&via=envs.net and I thought it was simple enough (and because Kakoune included it).

https://github.com/mawww/kakoune/issues/550 is the issue that motivated it in Kakoune. I think right now it could also be useful for basic multi-character pairs.

Overall, I agree that it is a niche command and if you guys don't want to include the command I'd be indifferent to it.

kirawi avatar Jan 30 '24 21:01 kirawi

The use-cases mentioned later in the issue are covered by surround tools. The original use-case I'm not sure I fully understand but it seems like it wouldn't come up often so I bet it could be covered instead by subselecting with a regex of ^.|.$. I've asked on matrix what the commenter's use-case is - I'm leaning towards not adding this unless there's something compelling

the-mikedavis avatar Jan 31 '24 15:01 the-mikedavis

so I bet it could be covered instead by subselecting with a regex of ^.|.$.

for selections that span across lines, \A.|.\z can be used instead to not match beginning/end of line

totallyuniquelily avatar Feb 22 '24 08:02 totallyuniquelily