在emacs中删除额外的空行 [英] delete extra blank lines in emacs

查看:142
本文介绍了在emacs中删除额外的空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

M-x flush-lines ^$ 

删除所有空白在缓冲区中的行。但是我只想删除额外的空行,也就是说如果有n个连续的空行,我想删除n-1并保留一个。

deletes all blank lines in a buffer. However I only want to delete extra blank lines, that is if there are n consecutive blank lines I want to delete n-1 and keep one.

我知道delete-空白线做了空白行的工作,但我想要一个简单的解决方案,适用于整个缓冲区。

I know that delete-blank-lines does the job for the blank lines under the point, however I want a simple solution which works for the whole buffer.

任何想法如何做到这一点?特别是可以从我的第一个例子修改正则表达式^ $,以仅匹配额外的行?

Any ideas how to do this? Especially is it possible to modify the regex ^$ from my first example to match only the extra lines?

推荐答案

C-x h M-x replace-regexp RET ^ C-q C-j C-q C-j + RET C-q C-j RET

标记整个缓冲区,并用单个空白行替换两个或多个空白行。

which marks the whole buffer and replaces two or more blank lines with a single blank line.

这篇关于在emacs中删除额外的空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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