正如我在erlang社区看到的那样,格式化代码的常用方法是emacs erlang模式的工作方式.
有没有办法调用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.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。