-
Notifications
You must be signed in to change notification settings - Fork 720
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
Find commands #5275
Comments
On Thu, Jan 16, 2025 at 10:23:55AM -0800, Don Allen wrote:
I am a very experienced vi and vim user. In the last year or
two, I've gotten interested in Kakoune and have used it a fair
amount. I've also read the arguments in favor of select first,
operate second. I want to mention something here that I have not
seen discussed.
In vim, I use the find (f and t) commands for two purposes:
1. I want to perform an operation on everything between where the
cursor is currently and the character to be found, e.g., 'dt,'.
2. I simply want to navigate to the found character and once there,
do a local operation, e.g., an insert or a replace.
interesting. I also use both, probably 2 is more frequent.
To do 2. in Kakoune, I need to be very careful. If, for example,
after a find I press 'i' with the intention of inserting at the
target character, the insertion takes place where I came from, not
where I'm at. I have to remember to collapse the selection that I
didn't want in this case. So it's more mental effort and an extra
keystroke than the same situation in vim.
In vim, I can run the find command by itself, not preceded by an
operator, which gets me to my target characer, where I can do
whatever operation I want at that site. If I want 1. above, then
I can precede the find with an operator. I have not found a way to
separate these two cases easily in Kakoune. It would help if there
were non-selecting versions of the find commands. I haven't figured
out a way to achieve that myself.
Here's a quick version that binds the nonselecting version to <space>f
(though it's perfectly fine to do "map global normal f" to)
define-command my-find-nonselecting %{
on-key %{
execute-keys "f%val{key};"
}
}
map global user f :my-find-nonselecting<ret>
|
Thanks -- that works. |
Though there is an issue. After using the non-selecting find, alt-. repeats the selecting find. |
On Thu, Jan 16, 2025 at 11:48:34AM -0800, Don Allen wrote:
Though there is an issue. After using the non-selecting find, alt-. repeats the selecting find.
Right. OTTOMH, a quick fix is to add another override for "<a-.>",
declare-option str my_maybe_reduce_selection
define-command my-repeat-last-movement %{
execute-keys "<a-.>%opt{my_maybe_reduce_selection}"
}
map global normal <semicolon> :my-repeat-last-movement<ret>
and then any f/t/F/T commands need to be updated to set
"my_reduce_selection" to ";" or clear it (probably in window scope).
|
I would like to add that my observation about the find commands extends to other movement commands as well that select -- w, b, etc. When you want to use movement commands to get somewhere to perform a local operation, which is frequently the case in my experience, I think the vi approach -- operation/selection by movement or just movement -- is superior in this way to Kakoune, where you do not have the option of not selecting by movement. So when you need this, you are forced to collapse the selection after the movement, an extra keystroke. And it's not only the keystroke, it's having to remember to do it, otherwise you get something you didn't intend. Yes, you can undo, but I that this aspect of Kakoune, well done as it is, reduces my editing efficiency. I know that the claim is that Kakoune beats vim in the vimgolf cases. I haven't looked carefully at them, but frankly, I don't care about those results. I care about my results and what I am finding is that Kakoune is not as efficient an editor for me as vim, nvim or vis. krobelus has been very helpful in showing me how to add the non-selecting commands and their analogous repeaters. But I'd have to do that with every movement command I use and then I have to remember to use non-selecting movement and repeater when necessary, which is a bigger issue. As opposed to just doing the movement, rather than the operation followed by a movement (which I think is a crucial brilliancy in Bill Joy's original vi design that has been sacrificed by the Kakoune select-then-operate approach) and the normal repeater in either case. |
I am a very experienced vi and vim user. In the last year or two, I've gotten interested in Kakoune and have used it a fair amount. I've also read the arguments in favor of select first, operate second. I want to mention something here that I have not seen discussed.
In vim, I use the find (f and t) commands for two purposes:
To do 2. in Kakoune, I need to be very careful. If, for example, after a find I press 'i' with the intention of inserting at the target character, the insertion takes place where I came from, not where I'm at. I have to remember to collapse the selection that I didn't want in this case. So it's more mental effort and an extra keystroke than the same situation in vim.
In vim, I can run the find command by itself, not preceded by an operator, which gets me to my target character, where I can do whatever operation I want at that site. If I want 1. above, then I can precede the find with an operator. I have not found a way to separate these two cases easily in Kakoune. It would help if there were non-selecting versions of the find commands. I haven't figured out a way to achieve that myself.
The text was updated successfully, but these errors were encountered: