vim:删除光标处的所有空白字符
是否有办法删除与光标同一行上的每个字符,一直到光标?例如,我可能有一行如下所示的代码:
foo = [cursor] Bar.new
如果我的光标位于上面的占位符处,是否可以删除每个空白字符(不使用正则表达式?),以便将 Bar.new 放置在光标处?
is there anyway to delete every character on the same line as a cursor, all the way up to the cursor? for instance, I might have a line of code that looks like the following:
foo = [cursor] Bar.new
If my cursor is at the place holder above, is it possible to delete every whitespace character (without using regex?) so that Bar.new is placed at the cursor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
d w
d w
根据你的例子,尼尔的答案是正确的。但是,根据您最初的问题,
你会输入 d 0
实际上,你在标题中问第三个问题......删除光标之前的所有空白字符。我不知道如果没有正则表达式该怎么做。 d g e 将删除所有向后引导的空白字符,直到出现非空白字符,但它也会删除第一个非空白字符。
Based on your example, Neall's answer is correct. However, based on your initial question,
you would type d 0
Actually, you're asking a third question in your title... delete all whitespace characters up to the cursor. That one I'm not sure how to do without regex. d g e would remove all the whitespace characters leading backwards until a non-whitespace, but it also deletes the first non-whitespace character.
不完全是你想要的,但也许 d i w 会有所帮助 - 在上面的例子中,它会删除所有
=
和Bar
之间的空白。也许 c i w space 会给你你正在寻找的结果?Not quite what you want, but perhaps d i w would help - in the example above, it would delete all the whitespace between the
=
and theBar
. Perhaps c i w space would give you the result you are looking for?d t B
将删除“B”之前的任何字符,但不包括“B”
d t B
Will delete any character up to, but not including the 'B'