Delete till end of sentence in vim

The solution was either dk which deletes the line and the line above it or dj which deletes the line and the line below it.

My original question was actually not the right question (there are multiple sentences).


) jumps to the beginning of next sentence, so d) will delete (from the cursor) till the beginning of the next sentence. Vim detects sentences using ., meaning period + space. This does mean that d) will have some problems if your cursor is on either the period or space delimiting two sentences, and will only delete until the first character of the next sentence (meaning it deletes either a space or the period and space, which is almost never what is desired). das will work as you probably expect, deleting the sentence and the delimiter (period + space).

If you specifically want to move (and delete to) the last character in a sentence it is more complicated according to this vi.SE answer:


Use das or dis to delete a sentence. Use dap or dip to delete a paragraph. See :help text-objects for details. Unrelated to your question, see this wiki page for plugins that provide other, highly useful text objects.


To delete to the end of the sentence, from where your cursor is, use the letters, use "d)". the "d" is the delete command object, followed by a motion object ")" which advances the cursor (and the deletion process) to the end of the sentence.

To delete "around" a sentence, including all the extra whitespace, use "das" (delete around sentence). Or to delete inside the sentence, and not all the whitespace, then use "dis" (delete inside sentence).

Once you understand the VIM language, then you can easily memorize a plethora of operations. Use this table to understand VIM's vocabulary:

COUNT NUMERAL + TEXT OBJECT COMMAND + MOTION (or OPERATORS) "3das" will perform "delete around sentence 3 times"

So, if practical, you could place a numeral followed by... a command:

d=delete 
y=yank  (into memory buffer to "put" later)
c=change (delete then insert new text)

and then a motion:

) = move cursor to end of sentence
( = move cursor to beginning of prior sentence
} = move cursor to the next paragraph
{ = move cursor to the beginning of the prior paragraph
w = move cursor to next word
b = move cursor back a word
$ = move cursor to the end of the logical line
0 = (zero) move cursor to the beginning of the logical line
G = move cursor to the end of the file
gg = move cursor to the beginning of the file
h, j, k, or l (you might have to look those up)

OR instead of a Motion, define a field of area using:

a = around
i = inside

followed by the name of the area around the cursor:

s = sentence
p = paragraph
w = word
t = xml-tag <tag example>  lots of text between tags </tag example>
< or > =  inside or around a tag, frequently found in xml documents
{ [ ( ) ] } = inside or around any type of bracket ...
... {a large area [some more (a little stuff) things] of a great many things }

Tags:

Vim