想象一下,我在Emacs下打开的文本文件中有以下内容:
some 34
word 30
another 38
thing 59
to 39
say 10
here 47
Run Code Online (Sandbox Code Playgroud)
我想变成这个,每个2位数字加1:
some 35
word 31
another 39
thing 60
to 40
say 11
here 48
Run Code Online (Sandbox Code Playgroud)
(这是一个简短的例子,我的实际需要是一个更大的列表,而不是我的电话)
我怎么能从Emacs做到这一点?
只要直接从Emacs进行调用并且仅在我想要的标记区域上操作,我不介意调用一些外部Perl/sed /任何魔法.
你会如何从Emacs自动化这个?
我认为我正在考虑的答案包括调用shell-command-on-region并用输出替换该区域......但我不确定如何具体地执行此操作.
在emacs中,在执行诸如此类的操作之后comment-region,将自动取消选择所选区域.
有没有办法禁用这种行为?
EMACS 24.1.我需要重新绑定Ctrl-space到一个自定义函数:
这是我的代码无效:
(define-key global-map [?\C- ] 'my-set-mark-command)
(defun my-set-mark-command()
(interactive)
(end-of-line)
(delete-char (* -1 (skip-chars-backward "\t\s")));;delete trailing spaces
(set-mark-command nil))
Run Code Online (Sandbox Code Playgroud)
当没有尾随空格时,它正常工作:开始选择并突出显示该区域.尾随空格:删除尾随空格,停在行尾,设置标记但不突出显示该区域.
如果我删除最后一个命令(set-mark-command)并且我手动运行它可以M-xset-mark-command工作.请有人帮助我使这个功能正常工作??