简体   繁体   English

VIM:命令清除当前行并进入插入模式

[英]VIM: command to clear current line and drop into insert mode

I am in normal mode, at the end of a line. 我处于正常模式,在一行结束时。 I want to clear the line (delete all characters of the line), and drop into insert mode so that I can start writing something else on that line. 我想清除该行(删除该行的所有字符),然后进入插入模式,以便我可以开始在该行上写入其他内容。 Is there a Vim shortcut for this? 这有Vim的快捷方式吗?

Ideally, I would like to preserve the leading whitespaces on the line, but even if I can't that should be fine. 理想情况下,我想保留线上的前导空格,但即使我不能这样做也应该没问题。

You can use S or c c to do that (synonyms). 您可以使用Sc c来执行此操作(同义词)。 They will keep your indentation if the autoindent option is on. 如果启用了autoindent选项,他们将保留缩进。 Both can accept an optional count if you want to remove multiple lines. 如果要删除多行,两者都可以接受可选计数。

You're looking for :help cc . 您正在寻找:help cc Without a [count] , cc deletes the entire current line and goes into insert mode. 如果没有[count]cc删除整个当前行并进入插入模式。 Works from anywhere in the line, not just at the end. 在线上的任何地方工作,而不仅仅是在最后。 Depending on your intent settings, that will be preserved, too. 根据您的意图设置,也将保留。

Possible alternatives: A<Cu> , or ddO . 可能的替代方案: A<Cu>ddO

I do not know the shortcut. 我不知道捷径。 But just to add, we can do this normally by using first "dd" to delete the line and pressing "o" to enter into insert mode for the deleted line. 但只是添加,我们可以通过使用第一个“dd”删除该行并按“o”进入已删除行的插入模式来正常执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM