-
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).
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: