brenton-leighton / multiple-cursors.nvim

A multi-cursor plugin for Neovim that works in normal, insert/replace, or visual modes, and with almost every command
Apache License 2.0
167 stars 4 forks source link

Add a command to move the cursor to the next word #4

Closed aimuzov closed 5 months ago

aimuzov commented 8 months ago

Hello! Thank you for the plugin. I have a suggestion. Would it be possible for you to implement focus shifting similar to how it is done in vscode? For example, upon pressing , it would highlight the next matching occurrence with the current selection (word).

Example from vscode docs:

multicursor-word

brenton-leighton commented 8 months ago

I'm not sure, is this just creating cursors by searching for words? If so, that's already something I'm planning to do.

brenton-leighton commented 5 months ago

Hi @aimuzov, someone has submitted a PR for a command like VS Code's Ctrl+D, so I realised that it adds a cursor one at a time. You could check this branch to see if it works the way you want it to.

aimuzov commented 5 months ago

Hi @aimuzov, someone has submitted a PR for a command like VS Code's Ctrl+D, so I realised that it adds a cursor one at a time. You could check this branch to see if it works the way you want it to.

Hi @brenton-leighton. This is exactly what I wanted. Thank you very much. When will this be in the main branch?

brenton-leighton commented 5 months ago

@bokenator mentioned adding a command to skip a match.

I'm just wondering, what is the functionality that you want? If it's just incrementally adding cursors (rather than a copy of VS Code's Ctrl+D)?

I ask because maybe these two commands would work better:

  1. Add virtual cursor to current cursor position, then jump to next match
  2. Jump to next match (without adding a virtual cursor)

The first command would be the opposite of what Ctrl+D does (it doesn't move the real cursor, just adds a virtual cursor to the next match) but it would mean that the second command will give some feedback when a match is skipped.

@bokenator is that OK for you?

bokenator commented 5 months ago

I agree. The proposal is even better. It's definitely helpful to have some feedback when a shortcut key is pressed. The only shortcoming I can think of is it'll be harder to return to the original cursor's location, but it doesn't affect my workflow and it's easy to write a custom function that creates a mark at the original cursor.

brenton-leighton commented 5 months ago

I've added the functionality to the feat_add_jump_next_match branch. There's two commands:

The branch also renames the other search commands:

@bokenator @aimuzov If there's no problems I will merge it.

@bokenator Restoring the cursor position when exiting multiple cursors sounds like a good idea, I'll probably add an option for that in the future.

bokenator commented 5 months ago

Sounds great!

Thanks you very much!

brenton-leighton commented 5 months ago

This is merged now. I'll tag a new release soon.