Emacs:删除空格或一个单词 [英] Emacs: delete whitespaces or a word

查看:1670
本文介绍了Emacs:删除空格或一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置emacs的工作方式与其他现代编辑器一样,按照 Alt + D Alt + Backspace 删除相邻的空格或单个单词?默认情况下,emacs总是删除一个单词。

How can I configure emacs to work in the same way as other modern editors where pressing Alt+D or Alt+Backspace deletes either adjacent whitespaces or a single word? By default, emacs always deletes a word.

推荐答案

通过一段时间使用Emacs,我认为即使我可以改变基本功能,通常在效率方面不会有很大的回报。事实上,在我做了几次之后,我来到后悔,没有解决。这不是所有的时间,一些键绑定是非常不舒服或很少有用的,但我不认为这是死亡词的工作原理。事实上,我刚才意识到:我在Eclipse中尝试过键盘绑定,但是我一直在使用Emacs风格的kebindings,因为永远...

Trough some time of using Emacs I figured that even though I can alter the basic functionality, it usually doesn't pay off much in terms of efficiency. In fact, after I did it several times, I came to regret it and undid it. This is not true all of the time, some keybindings are really uncomfortable or rarely useful, but I don't think this is the case with how kill word works. In fact, I just now realized that: I did try the keybinding in Eclipse, but I've been using it with Emacs-style kebindings since forever...

无论如何正如我刚才说的那样,在修复这个功能之前,确保它真的坏了:)我从来没有发现自己需要你所描述的那种功能,也许这就是为什么:

Anyways, as I just said, before you are "fixing" that functionality, make sure it is really broken :) I never find myself needing the kind of function you describe, and maybe here's why:


  1. M-SPC 将单词之间的空间减少到一个空格。这是我所用的,如果这个词之间的点,我想删除分隔词的额外空间。

  1. M-SPC reduces the space between words to just one space. This is what I would've used if the point was between the words and I wanted to delete the extra space separating the words.

M- \ 删除所有的水平空间。这将加入由空格分开的两个单词。

M-\ removes all horizontal space. This will join two words separated by space.

如果您想要实现的是某种稀疏格式,如:

If what you are trying to achieve is some kind of "sparse" formatting, as in:







int foo          = 42;
unsigned int bar = 43;

然后有 Mx align-regexp 这样做。

then there's M-xalign-regexp to do that.


  1. 我从来没有碰巧有一个长期的白蛋白的运行,除非它是缩进,在这种情况下是缩进, TAB 通常会更好地处理它。 b)即使有太多的空白的空白,所以我一次也很少把这个点移动一个角色,所以很难想到一个情况,我会发现几个空格所包围的点。事情像艺术家模式或点图想到,但它不会发生在代码编辑。

  1. I just never happen to have a) long consequent runs of whitepsace, unless it is the indentation, and in the case it is the indentation, TAB usually handles it better. b) even if there are long consequent runs of whitespace, I so rarely move the point by one character at a time, so it's hard to think of a situation where I'd find the point surrounded by several whitespaces. Things like Artist mode, or Dot diagrams come to mind, but it doesn't happen during code editing.

最后,如果你试图,我们假设只需编辑一个任意的文本文件,并且想要添加或删除单词之间的水平空间...再次,将 Mx align-regexp 这样做,或者您可以使用在矩形上操作的命令,如果那些是当时的几行。那么,Emacs甚至可以识别这个特别的标签,并尝试对齐文本,比如匹配最后一行,点击 TAB

Finally, if you are trying to, well, let's say just edit an arbitrary text file and you want to add or remove horizontal space between words... Again, there's M-xalign-regexp to do that, or you could use commands that operate on rectangles, if those are several lines at the time. Well, Emacs will even recognize the ad hoc tabs and will try to align the text such as to match the last line before the point, when you hit TAB.

最后,如果由于某种原因我不能理解:)我真的需要做你所描述的,然后我会这样做: k M-\ BACKSPACE (它可以是任何其他键而不是k - 它只是在你的手指下,所以它很快键入:)或者,如果我懒得想想: M-SPC Mf Mb Cw - 也许听起来很多,但这些都是您将一直使用的命令,所以它不会阻碍你的速度。

Finally, if for some reason I cannot fathom :) I really needed to do exactly what you describe, then I'd do it like so: kM-\BACKSPACE (it can be any other key instead of "k" - it is just right under your finger, so it's fast to type :) Or, if I'm lazy to think about it: M-SPCM-fM-bC-w - maybe sounds like a lot, but these are the commands you would be using all of the time anyway, so it doesn't hinder you in terms of speed.

这篇关于Emacs:删除空格或一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆