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

Doesn't work properly with change motions #3

Open
thalesmello opened this issue Jan 17, 2017 · 3 comments
Open

Doesn't work properly with change motions #3

thalesmello opened this issue Jan 17, 2017 · 3 comments

Comments

@thalesmello
Copy link

Suppose that I have the following snippet.

Hello mister Thomas
Hello mister Scott
Hello mister Edward

And that, from the first character in the first line, I type c2eGood morning<esc>

The result would be

Good morning Thomas
morning mister Scott
morning mister Edward
@AndrewRadev
Copy link
Owner

AndrewRadev commented Jan 18, 2017

I use the plugin mostly for variable renaming, and I find it very convenient that, if you edit a word with cw, it replaces only that word. So, replacing "one" with "two" will not touch "one_more_thing". On the other hand, whever I do want to replace anything without caring about word boundaries, I'd use visual mode.

In practice, in normal mode, the pattern is the word under the cursor wrapped in \< and \>, while in visual mode, it's the selected text wrapped in \V and \m (to avoid matching special characters).

Now, I'm pretty sure it's possible to just take the text that the motion operated on, and act on it the same way I do with visual mode. But that would drop the word functionality. I could add \< and \> on the text in normal mode, but I feel that wouldn't make sense in all cases.

An option might be to manually compare the text that the motion selected (only in normal mode) with the current <cword> and, if they're the same, add word boundaries. Not sure if that makes sense or not.

I'll think about it and see what I can do. If you can think of a sensible way for the plugin to work with word boundaries and text objects, let me know your thoughts.

@thalesmello
Copy link
Author

thalesmello commented Jan 18, 2017

That's exactly what I would expect from a multiple word replacement.

  • When you change motion a single word, do include \< and \> in the search.
  • When you change motion more than one word, make it behave the same way as visual mode.

Do you think it would be very complicated to implement?

Otherwise, I'd just accept this as a limitation and just use visual mode whenever I need this.

@AndrewRadev
Copy link
Owner

I'll try to implement it and see how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants