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

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

问题描述

如何将 emacs 配置为与按 Alt+DAlt+ 的其他现代编辑器相同的工作方式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 一段时间后,我发现即使我可以更改基本功能,但在效率方面通常不会带来太多回报.事实上,我做了几次之后,我开始后悔并取消了它.这并非总是如此,某些键绑定真的很不舒服或很少有用,但我认为 kill word 的工作方式并非如此.事实上,我刚刚意识到:我确实尝试过 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;

然后有 M-xalign-regexp 来做到这一点.

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

  1. 我从来没有碰巧有过 a) 长时间运行的 whitepsace,除非是缩进,如果是缩进,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.

最后,如果您想尝试编辑一个任意文本文件,并且您想添加或删除单词之间的水平空格...同样,还有 Mxalign-regexp 来做到这一点,或者您可以使用对矩形进行操作的命令,如果这些命令当时是几行.好吧,当您点击 TAB 时,Emacs 甚至会识别临时选项卡并尝试对齐文本,例如匹配点之前的最后一行.

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.

最后,如果由于某种原因我无法理解:) 我真的需要完全按照你的描述去做,那么我会这样做:kM-BACKSPACE(它可以是任何其他键而不是k"——它就在你的手指下,所以输入速度很快:) 或者,如果我懒得去想它:M-SPCMfMbCw - 也许听起来很多,但这些是你会用到的所有命令无论如何,它不会妨碍您的速度.

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天全站免登陆