Emacs - 删除第一个非空白字符

发布于 2024-12-10 05:20:52 字数 145 浏览 0 评论 0原文

我正在寻找从当前光标位置删除到第一个非空白字符的键绑定/功能

示例:

function f() {|

    test();

| - 光标位置

我想删除“t”字母的所有内容

I'm looking for key binding / function which delete from current cursor position to first non blank character

example:

function f() {|

    test();

| - cursor position

I want delete everything to "t" letter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

林空鹿饮溪 2024-12-17 05:20:52

在“c-mode”中,有 'Mx c-hungry-delete -forward',也绑定到 Cc Cd。因此,您可以在您使用的任何编程模式下创建该绑定。

(define-key <whatever>-mode-map (kbd "C-c C-d" 'c-hungry-delete-forward)

或者,您可以获取包 'hungry-delete' 并使用它来覆盖删除命令删除所有空格(而不是单个空格)。

In 'c-mode' there is 'M-x c-hungry-delete-forward', which is also bound to C-c C-d. So, you can create that binding in whatever programming mode you're using.

(define-key <whatever>-mode-map (kbd "C-c C-d" 'c-hungry-delete-forward)

Alternatively, you can grab the package 'hungry-delete' and use that to override the deletion commands to delete all the whitespace (as opposed to a single space).

各自安好 2024-12-17 05:20:52

Mz t t(根据需要替换t:)。

M-z t t (substitute t as needed :).

与他有关 2024-12-17 05:20:52

已经提出了很多好的选择。在 Emacs 24(目前处于预测试阶段)中,您可以将 M-- 指定为 just-one-spaceM-SPC 来执行以下操作:你问。

Lots of good options have been presented. In Emacs 24 (currently in pretest), you can specify M-- to just-one-space or M-SPC to do exactly what you ask.

残龙傲雪 2024-12-17 05:20:52

为此,我使用自定义宏:(

(fset 'jline
    [?\C-  ?\C-\M-n ?\C-a ?\C-w return])

只需将这个小宏放入您的 .emacs 配置中)

当然,您可以根据需要重命名该宏。


因此,以下状态:

function f() {|



    test();
}

变为:

function f() {
    |test();
}

To do this, I use a custom macro :

(fset 'jline
    [?\C-  ?\C-\M-n ?\C-a ?\C-w return])

(just put this small macro in your .emacs config)

Of course, you can rename the macro like you want.


So, the following state :

function f() {|



    test();
}

Becomes :

function f() {
    |test();
}
只怪假的太真实 2024-12-17 05:20:52

使用Mx delete-blank-lines(也绑定到Cx Co)。

从帮助文档 (Ch k Cx Co) 中:

  • 在空行上,删除所有周围的空行,只留下一个。
  • 在孤立的空白行上,删除该行。
  • 在非空行上,删除紧随其后的任何空行。

Use M-x delete-blank-lines (which is also bound to C-x C-o).

From the help-docs (C-h k C-x C-o):

  • On blank line, delete all surrounding blank lines, leaving just one.
  • On isolated blank line, delete that one.
  • On nonblank line, delete any immediately following blank lines.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文