vim: `f` and `t` multiline option
I'm not sure how compliant you're aiming to be with vim, but the f behavior is more useful when it can search on multiple lines instead of a single one, so I'd like to propose this change.
This change is quite frequent in vim/neovim as a plugin (e.g. clever-f, improved-ft, etc), and in other vim emulations (e.g. vscode-vim).
How does this work when I have multiple cursors or a visual block selection and I want each cursor only to search on its own line?
Good question, that's a difference with vim.
For visual block selection, it seems to act as if there was only one cursor, the last one, and all the other cursors follow the last one. This is not different than other motions right now, e.g. w does word motions on the last cursor and the other cursors follow the column position, regardless of the words on their own line.
For multiple cursors that end up on the same line, I haven't tested yet, depends what's the behavior right now when multiple cursors collide, but I haven't found a way to create multiple cursors in vim normal mode other than visual block selection.
Thanks for this! I like the idea of it, but think it is too far off from vim to support by default.
We recently added the ability to have vim-specific configuration options; so let's add an option:
{
"vim": {
"use_multiline_find": true
}
}
I'd happily pair with you to get this over the line: https://calendly.com/conradirwin/pairing. But if you want to take a pass yourself, you can use #7936 as inspiration for how the setting might work.
We'll also want at least one test for the new behavior so we don't break it by accident.
Sounds good, I think I have enough information to do it by myself.
but I haven't found a way to create multiple cursors in vim normal mode other than visual block selection.
FWIW you can use opt-click (it would be neat if we find a Vim-y way to this):
Gotcha, works on linux as alt-click. Played a bit with colliding selections/cursors and multiline find, it feels like the current behavior is good.
it would be neat if we find a Vim-y way to this
I see two solutions to create multiple cursors in a keyboard-centric way:
- Have a "create cursors" mode, where the user can move like in normal mode and mark locations for new cursors, and once complete all the marks turn to cursors.
- Inspired by atom-vim-mode-plus and kakoune selections, we can add a command that adds cursors at either pre-defined patterns (e.g. word boundaries, other matches for current word, etc) or user-inputed patterns (regex). In conjunction with visual mode or operator-pending mode, it's a very efficient way to add cursors.
Once we get linux working I'd definitely be interested in spending some time on the vim implementation.
This is ready for review. I've added a small section to the docs for the vim settings.
Great, thanks so much for this!
I'd love to talk through the multi-cursor thing before you jump in and implement anything.