英文:
Setting specific macro only run for certain file extension on IntelliJ
问题
我在IntelliJ上有一个宏,可以格式化代码并保存:

我将键盘快捷键Ctrl+S分配给了这个宏:

这对于css、js和html都很有效。
问题是,内置的go-lang-idea-plugin与gofmt(由我的自动重新加载/自动重新编译程序gin调用的格式化程序,当源代码在磁盘上发生更改/保存时运行)产生不同的结果,所以.go源代码的ReformatCode命令是无用的。
如何仅在.go文件中禁用该宏?这样,当我使用Ctrl+S保存时,它只执行SaveAll操作?
英文:
I have a macro on IntelliJ that format the code then save:

I have assigned keyboard shortcut Ctrl+S to that macro:

This works well for css, js, and html.
The problem is, the built-in go-lang-idea-plugin gives different result from gofmt (formatter program that called by my auto-reload/auto-recompile program gin that runs when the sources changed/saved on disk)
so the ReformatCode command for .go source code is useless.
How to disable that macro only for .go file? So when I save using Ctrl+S, it only do SaveAll?
答案1
得分: 1
尝试使用文件监视器插件来解决这个问题,而不是使用宏。插件的链接是:https://github.com/go-lang-plugin-org/go-lang-idea-plugin/issues/1324#issuecomment-75263115
英文:
Try using the File Watcher plugin instead of macros to solve this issue: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/issues/1324#issuecomment-75263115
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论