Emacs:如何使其成为午夜指挥官中的编辑器?
我的问题是关于午夜指挥官的。我已经取消设置内部编辑器的使用(在“选项”->“配置”中)并放入 .bashrc
:
export EDITOR='emacsclient -n'
仍然 - 按 F4 没有给出任何内容,按 F3 - 在 vi
中打开。有没有办法让 emacsclient
成为 mc
中的默认文本编辑器?
My question is about Midnight-commander. I've unset usage of internal editor (in Options -> Configuration) and put in .bashrc
:
export EDITOR='emacsclient -n'
still - pressing F4 gives nothing, pressing F3 - opens in vi
. Is there a way to make emacsclient
to be a default text editor in mc
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我找到了一个办法:可以使用mc的宏功能。为此,创建一个文件:
并将其保存为
~/.mc/menu
或~/.mc.menu
。之后按F2
- 您将获得您的功能列表。并且将有一个函数Open in emacs
- 可以通过e
访问该函数。因此,F2-e
两个键在emacsclient -n
中打开当前文件(或所有选定的文件)。I found a way: one can use mc's macro feature. For that make a file:
and save it as
~/.mc/menu
or~/.mc.menu
. After that on pressinF2
- You'll get a list of Your's functions. And there will be a functionOpen in emacs
- which will be accessible by thee
. So the two keysF2-e
open current file (or all selected files) inemacsclient -n
.我所做的是更改 ~/.mc/bindings 文件:
这样我仍然可以使用 F3 查看文件,但 F4 或 Enter 通常会使用 Emacs 编辑它们。
顺便说一句,&号是为了让文件在X中弹出,我可以在mc中继续。如果您只在命令行上工作,则可能必须删除它。
更新:如果您没有
~/.mc/bindings
文件,请从 mc 内部按 F9 c e(菜单、命令、编辑扩展文件),它应该可以帮助您到达那里。此外,您需要关闭内部编辑选项,方法是转到F9 oc t(菜单、选项、配置、使用内部编辑),取消选中该框,然后保存选项。
What I do is change the ~/.mc/bindings file:
That way I can still view files with F3, but F4 or enter usually edits them with Emacs.
By the way, the ampersand is so that the file will pop up in X, and I can continue in mc. You may have to remove that if you're only working on the command line.
UPDATE: If you don't have a
~/.mc/bindings
file, from inside mc, press F9 c e (Menu, Commands, Edit extension file), and it should get you there.In addition, you need to switch off the internal edit option by going to F9 o c t (Menu, Options, Configuration, use Internal edit), unchecking the box, and then saving the options.
像往常一样运行 MC。在菜单选项底行上方的命令行中,键入不带引号的“select-editor”。这应该会打开一个菜单,其中包含所有已安装的编辑器的列表。这对我当前所有的 Linux 机器都有效。
Run MC as usual. On the command line right above the bottom row of menu selections type "select-editor" without the quotes. This should open a menu with a list of all of your installed editors. This is working for me on all my current linux machines.
这是另一个解决方案:编辑扩展文件并添加编辑条目。
(抱歉,没有足够的声誉将此作为评论添加到 Gustav Bertram 的答案中。)
请务必使用 MidnightCommander 的内置功能,因为配置文件的位置似乎在某些版本的 MC 之间发生变化。
因此,请按
F9
或ESC,9
(打开菜单),然后转到Command ->编辑扩展文件
。在编辑器中,找到最后一个块,如下所示:
将其更改为类似的内容(注意添加的
Edit
行!!!):保存后文件,请务必关闭内部编辑器关闭!!
(
F9
或ESC,9
,选项 -> 配置
,必须取消选中“使用内部编辑
”)这样(至少适用于更高版本的 MC)您可以使用三种不同的编辑器(或命令行选项)来打开文件:“查看”(
F3
)、“编辑”(F4
)和“打开” (Enter
) - 每个都可以单独配置。注意 #1:如果您添加了自定义
view
命令,请不要忘记取消选中Options - 下的“
。使用内部视图
” >配置注意#2:从 MC 中打开配置文件时,MC 仍然使用其首选编辑器(例如 nano)来编辑配置文件。
Here is another solution: edit the extension-file and add an Edit-entry.
(Sorry, not enough reputation to add this as comment to Gustav Bertram's answer.)
Be sure to use MidnightCommander's built-in functionality, as the location of config-files seems to change between some versions of MC.
So press
F9
orESC,9
(to open the menu), then go toCommand -> Edit Extension File
.In the editor, find the last block looking like that:
Change it to something like that (note the added
Edit
-line!!!):After saving the file, be sure to turn the internal editor off!!
(
F9
orESC,9
,Options -> Configuration
, "Use internal edit
" must be unchecked)That way (working at least with later versions of MC) you can have three different editors (or command-line options) to open a file: "View" (
F3
), "Edit" (F4
) and "Open" (Enter
) - each individually configurable.Note #1: If you added a custom
view
-command, do not forget to uncheck "Use internal view
" underOptions -> Configuration
.Note #2: MC still uses its preferred editor (e.g. nano) for editing config-files when opening them from within MC.
删除~/.selected_editor,下次按F4时MC会提示选择编辑器。或者,您也可以直接更改它。
这适用于 Ubuntu。我尝试过任何其他方法来设置默认编辑器,但没有帮助。
Remove ~/.selected_editor, then when you press F4 next time, MC will prompt for select editor. Or, you may directly change it.
This works on Ubuntu. I have tried any other ways to setup default editor which won't help.