Enabling/Disabling IntelliJ的花式≠(不等于)运算符

Enabling/Disabling IntelliJ's fancy ≠ (not equal to) operator

我在 GOTO 2016 • Kotlin - Ready for Production conference by Hadi Hariri.

中目睹了这一点

在他的一些代码中,通常是这样的:

if (x != y) { /* do some stuff */ }

正在展示的优雅风格:

if (x ≠ y) { /* do some stuff */ }

代码使用常规 != 运算符,IDEA 会处理其余部分。

那么,我该如何启用它?

To enable ligatures, go to the Settings → Editor → Colors & Fonts → Font, choose a font that supports ligatures, e.g. FiraCode, Hasklig, Monoid or PragmataPro (the font has to be installed) and select the Enable font ligatures option.

来源:link.

要预览一些字体,包括一些带有连字的字体:https://app.programmingfonts.org/

这是"font ligatures",这是某些字体的一个特性,可以将两个字符显示为一个符号(但是这两个字符仍然存在于文件中)。您可以在首选项页面中搜索 "ligatures" 并选中以启用。您还需要使用支持连字的字体,例如 Fira Code。

我在 Android Studio 4.0 中使用 Material 设计主题,导航至:

File->Settings->Editor->Color Scheme->Color Scheme Font

并选中启用字体 Ligatures.Do 同样适​​用于:

File->Settings->Editor->Color Scheme->Console Font.

这是在 inteliJ 中选择 FiraCode 作为你的字体之后。找到它 here 并将其安装为普通字体。

这是“字体连字”功能,它使用了 2020.3 中引入的 ligatures to combine the characters in fonts that support them. This feature is disabled by default in the standard editor, and enabled by default in the Reader mode

可以在 project settings window 中为当前项目启用和禁用此功能(Windows 和 Linux 或 [=11 中的File | Settings… =] 在 macOS 中)。

设置位于 window 的设置中:

  • 编辑器Editor | Font -> “启用字体连字”复选框
  • Reader 模式Editor | Reader Mode -> “字体连字”复选框

Goland 2020.3(可能还有其他版本)似乎有一个错误。启用和禁用 Goland -> Preferences -> Editor -> Font -> Enable font ligatures 对普通文件有效,但对以下文件无效vendor/ 目录。这些文件需要关闭并在编辑器中重新打开。