在 Eclipse 中设置自定义语法高亮的快速方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10837035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Quick way to set custom syntax highlighting in Eclipse
提问by Donovan
I know I'm not the first to need this. I am working on an in house created codebase and I would like to apply highlighting to it within Eclipse. In Notepad++ I can set language for the file I'm looking at. Is there any way to do this for Eclipse?
我知道我不是第一个需要这个的人。我正在处理内部创建的代码库,我想在 Eclipse 中对其应用突出显示。在 Notepad++ 中,我可以为我正在查看的文件设置语言。有没有办法为 Eclipse 做到这一点?
The code I'm working on would use the same syntax styling as C++.
我正在处理的代码将使用与 C++ 相同的语法样式。
回答by Andrew Eisenberg
Your best bet is to go to Preferences -> General -> Editors -> File associations. Add the file extension of the thing you are trying to open and add the C++ editor as the associated default editor.
最好的办法是转到首选项 -> 常规 -> 编辑器 -> 文件关联。添加您尝试打开的内容的文件扩展名,并将 C++ 编辑器添加为关联的默认编辑器。
If there is no file extension, then things are a little harder. Instead of double-clicking to open the file, right-click -> Open with... -> other -> C++ editor. This will remember your choice for that file only.
如果没有文件扩展名,那么事情就有点困难了。不是双击打开文件,而是右键单击 -> 打开方式... -> 其他 -> C++ 编辑器。这将仅记住您对该文件的选择。
回答by Gabriel Staples
As Andrew Eisenberg said, go to Window--> Preferences--> General--> Editors--> File Associationsand ensure your choices for editor for each file type are correct according to your desires.
正如Andrew Eisenberg 所说,转到Window--> Preferences--> General--> Editors-->File Associations并确保根据您的需要为每种文件类型选择的编辑器是正确的。
However, for Eclipse CDT most of your file types are set in Preferences--> C/C++--> File Typesinstead.
但是,对于 Eclipse CDT,大多数文件类型都设置在Preferences--> C/C++--> 中File Types。
Also, like he said, you can use the right-click menu to choose your own editor, including an external system editor, such as Sublime Text 3, Atom, Visual Studio Code, Notepad++, etc.
Right click on the file--> Open With--> Other...--> choose an "Internal editor" or "External program" to your liking, optionally checking the box at the bottom to make this the default choice next time.
另外,就像他说的,你可以使用右键菜单选择你自己的编辑器,包括一个外部系统编辑器,比如Sublime Text 3、Atom、Visual Studio Code、Notepad++等
Right click on the file--> Open With--> Other...-- > 根据您的喜好选择“内部编辑器”或“外部程序”,可选择选中底部的框,使其成为下次的默认选择。