vim - 使用 vim 作为编辑器,而使用 emacs 作为代码格式化程序

标签 vim emacs erlang

正如我在 erlang 社区中看到的,格式化代码的常用方法是 emacs erlang 模式的做法。

有什么方法可以调用 emacs 来格式化 vim(行、选定文本和孔文件)中的代码?

如果有人向我指出一些描述此缩进逻辑的 emacs 文档,我也将不胜感激?

编辑:实际上我知道如何从 vim 调用某些东西,但我不知道从 emacs 端调用什么。

最佳答案

intellij erlang 插件正是这样做的:ErlangEmacsFormatAction.java

/*
 * Copyright 2013 Sergey Ignatov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */

final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath("emacs");
commandLine.addParameters("--batch", "--eval");

String s = "\n" +
    "(progn (find-file \"{0}\")\n" +
    "    (require ''erlang-start)\n" +
    "    (erlang-mode)\n" +
    "    (untabify (point-min) (point-max))\n" +
    "    (delete-trailing-whitespace)\n" +
    "    (erlang-indent-current-buffer)\n" +
    "    (write-region (point-min) (point-max) \"{1}\")\n" +
    "    (kill-emacs))";

  commandLine.addParameter(MessageFormat.format(s, virtualFile.getCanonicalPath(), tmpFile.getCanonicalPath()));

它以文件作为参数之一调用 emacs 批处理子进程。在 vimscript 中实现类似的东西应该很容易,检查 Vim External Commands .

关于vim - 使用 vim 作为编辑器,而使用 emacs 作为代码格式化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15745031/

相关文章:

ubuntu - 如何在 Ubuntu 18/19 上升级 Elixir 版本

concurrency - 用 Erlang 写传统的并发问题容易吗?

node.js - 如何从 node.js 打开终端应用程序?

Vim Undo 命令(大写 U 的那个)

git - 在 git 中切换分支时,如何让 Emacs 恢复所有未更改的缓冲区?

emacs - isearch/在 emacs 中出现可见区域

web-services - Elixir用洗涤剂和洗涤剂调用Axis2 Java SOAP Web服务

regex - 正则表达式之谜

vim - 如何通过 viewdoc 插件在 Vim 中使用 pman 和自定义帮助文件?

shell - 是否可以从 emacs 向 xterm 发送 'cd' 命令?