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

Allow chaining find_next_char, select_textobject_around, etc. together with other commands in keymaps #4013

Closed
tmke8 opened this issue Sep 28, 2022 · 4 comments · Fixed by #4709
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements

Comments

@tmke8
Copy link

tmke8 commented Sep 28, 2022

There are quite a few commands that expect an argument in the form of a single character:

  • find_till_char
  • find_next_char
  • till_prev_char
  • find_prev_char
  • surround_add
  • surround_replace (this one even expects two arguments)
  • surround_delete
  • select_textobject_around
  • select_textobject_inner

However, it doesn't seem possible to chain these together with other commands in keymaps.

For example:

[keys.normal]
f = ["find_next_char", "collapse_selection"]

does not work as expected. The collapse_selection command seems to be completely ignored.

Similarly, this

[keys.normal]
C = ["select_textobject_inner", "change_selection"]

seems to execute the change_selection command immediately, before select_textobject_inner has finished.

My enhancement request is that if these commands with arguments appear in a keymap, they should first finish completely and then the next command in the list should be called.

@tmke8 tmke8 added the C-enhancement Category: Improvements label Sep 28, 2022
@kl
Copy link

kl commented Oct 12, 2022

I'm taking a stab at fixing this. I got a fix that works but needs a bit more work before I open a pull request.

@mitsuhiko
Copy link
Contributor

The ones related to select_textobject_inner are basically sub menus but the commands behind the items in the popup do not have command names themselves. For instance there really should be IMO a select_textobject_inner_word to do miw. I wonder if it would be a good idea to just name those commands and expose them for custom mappings.

@genepg
Copy link

genepg commented Nov 5, 2022

Although w, e and b, are great for selecting words automatically, I think f should change the default behavior like the key map below. In my case, It's more common for using without selecting. Is there any common case of using f with selection?

[keys.normal]
f = ["find_next_char", "collapse_selection"]

@webdev23
Copy link

webdev23 commented Dec 31, 2023

Not sure why, but to chain some commands, sometimes they requires a :, and sometimes not:
The following works fine for me. (Typing AltGr + d output ð on my French keyboard)
Notice the erratic usage of :.
It is a confusing behavior.

# Works fine: Duplicate line with AltGr + d
"ð" = ["extend_line_below", ":clipboard-yank", "open_below", ":clipboard-paste-before"]
# Doesn't work: Fail to load config (due to : on open_below)
"ð" = ["extend_line_below", ":clipboard-yank", ":open_below", ":clipboard-paste-before"]

@pascalkuthe pascalkuthe added A-keymap Area: Keymap and keybindings and removed A-helix-term Area: Helix term improvements labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements
Projects
None yet
7 participants