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

Using 'cx' {motion} followed by 'cxx' has strange behavior #42

Closed
kevintraver opened this issue Aug 7, 2016 · 2 comments
Closed

Using 'cx' {motion} followed by 'cxx' has strange behavior #42

kevintraver opened this issue Aug 7, 2016 · 2 comments

Comments

@kevintraver
Copy link

kevintraver commented Aug 7, 2016

This seems like an edge case, but using cx {motion} , followed by cxx doesn't seem to work as expected.

Example:

1 word
2 this is a sentence
3
4 

Use cxw on line 1, and then use cxx on line 2, will produce:

1 
2 this is a sentence
3 
4 word
@tommcdo
Copy link
Owner

tommcdo commented Aug 7, 2016

This is just what it looks like to mix linewise and chararacterwise motions. When you try to paste linewise content (the line targeted by cxx) over a characterwise selection (the word targeted by cxw), the result is that the linewise content is still on its own line. Here's an example that illustrates it more clearly:

1 before word after
2 this is a sentence

Use cxw on word and cxx on line 2. The result:

1 before 
2 this is a sentence
3 after
4 word  

While this is probably not what you wanted, it's much easier to understand why it happened. The linewise motion defined by cxx wants to continue being its own line. If we remove before and after, we actually see the exact same behaviour that you described.


For your case, you could use matching -wise motions to achieve the result you want:

  • cxw and cx$
  • cxx and cxx

@tommcdo tommcdo closed this as completed Aug 7, 2016
@kevintraver
Copy link
Author

Ah, thanks for the explanation, that makes sense now. And yes, using matching -wise motions is probably a better idea.

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