-
Notifications
You must be signed in to change notification settings - Fork 13
cw edge cases: cursor on a space, support cpo-z (Vim), cpo-_ (Neovim)
#85
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
base: master
Are you sure you want to change the base?
Conversation
|
This is now completed |
|
a82ad9a: nonfunctional change but makes it much easier to understand the code. |
Resolves chaoren#84 Resolves half of chaoren#69 Additionally, when cursor is at a "space-like", such as the underscore in a snake case word: foo_bar ^ Fixes that it should only remove the underscore and not the word after.
Resolves the rest of chaoren#69 To have `cw` work similarly to `dw` and delete the spaces after a word, set this option: set cpoptions-=z (Vim) set cpoptions-=_ (Neovim)
When cpo-z was not supported, we called it l:cw and did it unconditionally on cw command. Now we call it l:cw_special_case to differentiate, and only have to check if cursor is on whitespace in one place.
3e8c270 to
a82ad9a
Compare
|
Small change on comment: Made it clearer that what was previously a Now there's nothing I want to add further |
autoload/wordmotion.vim
Outdated
| let l:cw_special_case = 0 | ||
|
|
||
| if l:cpo_z != -1 && a:mode == 'o' && v:operator == 'c' && l:flags == '' | ||
| let l:cursor_on_s = matchstr(getline('.'), '\%' . col('.') . 'c' . l:s) != '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most important line to look at here,
Is there a better way to detect whether the cursor is on a part considered 'space' by vim-wordmotion, including _ or - delimiters in words?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the s:s regex? I believe there's a regex anchor for the cursor position, so you might be able to use those together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I'll see soon if I can simplify this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A much more understandable version on d81a78b
Btw just for clarity on l:s as it's not visible here and I worded the question a little confusingly:
let l:s = a:uppercase ? s:us : s:s|
I've learned now that removing in vim's helpfiles:
I'll have to investigate:
By the way, hope it's okay to add these (very minimal) nvim compatibility checks: the few |
|
To reproduce
With Without Tested with (I don't oppose replicating it for Vim to be absolutely faithful to the source, but at least not in the scope of this PR) I'd say this PR is finished. |
|
Thanks for the PR! Apologies for the delay. I don't have access to my PC at the moment, so I can't review or test this in detail right now. Thank you so much for the detailed research and testing! I only added the |
|
Great to know you're interested in this! No hurry at all
It started off simple but ended with a whole rabbit hole 😄 like usual
Yeah sounds good, also related to this plugin the cpo options for the |
|
Correction on Actually it's the opposite: there is only Meaning, this section is still in nvim ref: #85 (comment) |

Resolves: #69
Resolves: #84
It looks quite trivial to add support for:
cpo-z(Vim)cpo-_(Neovim)Doing that next on a separate commit