vim:删除光标处的所有空白字符

发布于 2024-09-25 06:33:59 字数 179 浏览 6 评论 0原文

是否有办法删除与光标同一行上的每个字符,一直到光标?例如,我可能有一行如下所示的代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

拥醉 2024-10-02 06:33:59

d w

d w

小帐篷 2024-10-02 06:33:59

根据你的例子,尼尔的答案是正确的。但是,根据您最初的问题,

有没有办法删除所有
与 a 在同一行的字符
光标,一直到光标处?

你会输入 d 0

实际上,你在标题中问第三个问题......删除光标之前的所有空白字符。我不知道如果没有正则表达式该怎么做。 d g e 将删除所有向后引导的空白字符,直到出现非空白字符,但它也会删除第一个非空白字符。

Based on your example, Neall's answer is correct. However, based on your initial question,

is there anyway to delete every
character on the same line as a
cursor, all the way up to the cursor?

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.

长安忆 2024-10-02 06:33:59

不完全是你想要的,但也许 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 the Bar. Perhaps c i w space would give you the result you are looking for?

野侃 2024-10-02 06:33:59

d t B

将删除“B”之前的任何字符,但不包括“B”

d t B

Will delete any character up to, but not including the 'B'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文