Is there a shortcut in vim to delete from the current cursor to the end of the sentence?
cursor
v
This is half a sentence. My cursor is here, but I would
like to delete to this period. I do not want to delete this part.
^
delete from cursor to here
Imagine my cursor is somewhere on the text that says My cursor is here,
. How can I delete from this line all the way (and including) that next .
?
Though there's no exact motion for that, there are several possibilities:
)
motion deletes the remainder of the sentence, but that also includes the whitespace after the period.f
motion (which only works in the current line, unless you install a plugin): f.
This is also useful if you want to keep the period: t.
/
. You need to search for a literal period (\.
), and to include it, move to the end (/e
) of it: /\./e<Enter>
.All of these have to be appended to the d
"delete" command, which takes a {motion}
.
Learn how to look up commands and navigate the built-in :help
(here, :help motion.txt
in particular); it is comprehensive and offers many tips. You won't learn Vim as fast as other editors, but if you commit to continuous learning, it'll prove a very powerful and efficient editor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With