我有给定的文本:
# Blub
Hello this is a blub text.
# Bla
This is the bla text.
# Abba
Another text.
是否可以对带有#
的行进行排序?这样得到的文本是:
# Abba
Another text.
# Bla
This the bla text.
# Blub
Hello this is a blub text.
最好使用 vim 或 emacs。
最佳答案
在 Emacs 中,
- M-x
排序正则表达式字段
- 输入:
#[^#]*
- 输入:
\&
第一个正则表达式分隔记录,第二个指定排序键。
如果您可以自由选择标记字符并使用 *
而不是 #
,您可以使用 org-mode 的命令 org-sort-entries
代替,这样可以避免输入正则表达式。
关于sorting - 对文本中的特定行进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11483758/