Delete to end of sentence in vim

So, I play virtual adventures and I'm stuck. I need a Vim command that will remove the keys in red. I thought dd would do this, but that would only delete the current line.

enter image description here

+11
vim
source share
7 answers

Use d a s or d i s to delete the sentence. Use d a p or d i p to delete the paragraph. See :help text-objects more details. Not related to your question, see this wiki page for plugins that provide other, very useful text objects.

+13
source share

) moves to the beginning of the next sentence, therefore d) deletes (from the cursor) before the start of the next sentence. Vim discovers sentences using . , which means dot + space. This means that d) will have some problems if your cursor is on the dot or space that borders the two sentences, and will only delete up to the first character of the next sentence (that is, it will remove either a space or a period and a space, which is almost never desired). das will work as you probably expect, removing the sentence and delimiter (dot + space).

If you specifically want to move (and delete) the last character in a sentence, it will be harder according to this vi.SE answer :

+9
source share

You can use the command: d 2 d , but I do not know if it works in the game.

+1
source share

Another option (not sure if it works in the game) is to delete before and including the period:

d / \ . / e

You should avoid the period by using a search pattern similar to this after the delete command.

If you are limited to one line, this is much simpler:

d f .

+1
source share

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 initial question was actually not correct (there are a few suggestions).

+1
source share

If you want to remove from J to and include the beginning . in J and use df.

If you want to delete both lines then 2dd

0
source share

Literacy Vim - [Nubmer] [Operator / Command] [Object of movement or text]

So in this case you can use: 2dd

0
source share

All Articles