在vim中删除到句末

Aak*_*des 11 vim

所以我正在玩vim冒险而且我被卡住了.我需要一个Vim命令来删除红色键.我以为dd会这样做,但那只会删除当前行.

在此输入图像描述

lcd*_*047 14

使用dasdis删除句子.使用dapdip删除段落.详情:help text-objects请见.与您的问题无关,请参阅 Wiki页面以获取提供其他非常有用的文本对象的插件.

  • 供参考:“d”删除下一个对象。`s` 代表句子。`a` 表示“周围”,“i” 表示“内部”。它们之间的区别是空白。虽然人们期望“ds”或“dS”(或类似的)从光标删除到句子的结尾/开头,但需要使用“(”和“)”来实现这一点。 (2认同)

Ale*_*dro 9

该主题中的查询答案"删除到vim中的句子结尾"尚未发布.它可能对OP没有用,但对于未来的搜索者来说也是如此.

)跳到下一个句子的开头,所以d)将删除(从光标)直到下一个句子的开头.需要注意的一个缺陷是,vim通过句点和两个空格检测同一段落中两个句子的界面.如果你在一段时间后有一个空格,它将经过它并删除下一个句子.

如果您特别想要移动(并删除)句子中的最后一个字符,根据此vi.SE答案,它会更复杂:


Aak*_*des 6

解决方案是dk删除该行及其上方的行,或者dj删除该行及其下方的行。

我原来的问题实际上不是正确的问题(有多个句子)。


use*_*711 5

要从光标所在位置删除到句子末尾,请使用字母,使用“d)”。“d”是删除命令对象,后面跟着一个运动对象“)”,它将光标(和删除过程)前进到句子的末尾。

要删除句子“周围”,包括所有多余的空格,请使用“das”(删除句子周围)。或者要删除句子内部,而不是所有空格,则使用“dis”(删除句子内部)。

一旦你理解了VIM语言,那么你就可以轻松记住大量的操作。使用此表来了解 VIM 的词汇:

计数数字 + 文本对象命令 + 动作(或操作员)“3das”将执行“删除句子周围 3 次”

因此,如果可行的话,您可以在后面放置一个数字...命令:

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

然后是一个动议:

) = 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)
Run Code Online (Sandbox Code Playgroud)

或者使用以下命令定义面积场,而不是运动:

a = around
i = inside
Run Code Online (Sandbox Code Playgroud)

后跟光标周围区域的名称:

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 }
Run Code Online (Sandbox Code Playgroud)