Skip to content

Comments

Consider punctuation when moving forward#51

Open
Strike-F8 wants to merge 5 commits intobkad:masterfrom
Strike-F8:master
Open

Consider punctuation when moving forward#51
Strike-F8 wants to merge 5 commits intobkad:masterfrom
Strike-F8:master

Conversation

@Strike-F8
Copy link

@Strike-F8 Strike-F8 commented Oct 22, 2025

Adding these two entries to forward_to_next_list should cause forward motion to additionally stop at punctuation just like vim default behavior. This prevents the occasional undesired behavior of consuming punctuation when using dw or cw.

Tested using Neovim v0.11.4.

I am not good with regex so I asked ChatGPT to create these two lines for me. It seems to be working but I'm sure there are cases I haven't tested.

Strike-F8 and others added 2 commits October 22, 2025 10:50
Adding these two entries to forward_to_next_list should cause forward motion to additionally stop at punctuation.
This prevents the occasional undesired behavior of consuming punctuation when using dw or cw.

Tested using Neovim v0.11.4
Ensure that dw deletes the last character of the last word of the line
without touching the next line.
CamelCaseMotion was inconsistently grabbing the next line when deleting
the last word of the line but this should prevent that from happening.
@Strike-F8
Copy link
Author

Added another commit that improves handling of the last word of a line.
This should ensure the last character of the last word of the line is deleted without touching the following line.
Before, if the next line was empty, it would work properly, but if there was another word to jump to, it would eat the new line.

This still doesn't fix deleting the very last word of the file but that's a rare case.

@Strike-F8
Copy link
Author

It turns out that it still crosses over to the next line if there is whitespace at the beginning of the line. I haven't figured out how to prevent this.

Edward Fernandez added 3 commits February 24, 2026 10:05
When on the last word of the current line, interrupt the 'dw' command and replace it with a 'd$' to ensure the motion does not cross over the new line
Replace 'dw' with 'd$' also at the last word of the last line of the file.
Also replace de with d$ only when at the last word of the file. This fixes de not deleting the last character as it should.
@Strike-F8
Copy link
Author

Several months later, I finally got around to looking at this again.

I'm not sure if this is the most elegant fix but dw and de should be exhibiting normal behavior. Meaning:

  • dw never crosses new lines. When at the last word of a line, dw is intercepted and replaced with d$
  • At the last word of the last line of the file, dw and de are both intercepted and replaced with d$, deleting until the last character

During my testing, I noticed that using de at the last character of a line deletes all blank lines up until the first non-blank line and then also deletes the first word of that line. But, if that line only has one word on it, it doesn't delete the last character! 🤷

I rarely, if ever, use de at the last character so it won't affect me but it is something to keep in mind.

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

Successfully merging this pull request may close these issues.

1 participant