Firacode: Ligature Request: =~ and !~

Created on 21 Oct 2016  Β·  6Comments  Β·  Source: tonsky/FiraCode

In Ruby and Perl there is =~ to match a pattern (regex) and !~ to not match a pattern:

"foo" =~ /o/
"foo" !~ /o/

It would be nice to have ligatures for both of these operators.

I propose the _almost equals sign_ and the _not almost equals sign_:

"foo" β‰ˆ /o/
"foo" ≉ /o/

(Adjusted for width, of course)

Regarding #167 (export PATH=~/.local/bin:$PATH) – I thinks it's safe to "activate" these ligatures only when there is whitespace around them (which is the idiomatic way to write the operators in both, Ruby and Perl): X =~ Y would trigger, X=~Y would not.

stylistic sets suggestion

Most helpful comment

Another option, which would preserve the distinct parts of the original operators:

foo β‰… /o/
foo ≇ /o/

All 6 comments

These ligatures seem pretty invasive to me. They completely change the perception of the actual operator which has a specific meaning in these languages. I think readers would get confused when seeing them, but that's just my personal opinion.

Another option, which would preserve the distinct parts of the original operators:

foo β‰… /o/
foo ≇ /o/

Where the tilde is used for the home directory it is almost always immediately followed by a slash. This could have been used to suppress the ligature and thus handle #167. Regular expressions are also often enclosed by slashes, but there usually is a space before the leading slash.

@Drenmi's suggestion of an elongated or centered U+2245 β‰… for =~ seems sound, but for !~ I'd rather expect something like U+2249 ≉ instead of U+2247 ≇, U+2246 ≆ or U+2244 ≄. There does not seem to be a precomposed character in Unicode of a single tilde with diagonal strike-through.

On second thought, ~= consitutes a precedent. It is rendered as an elongated U+2243 ≃ currently, so =~ could also become an elongated U+2242 ≂.

but there usually is a space before the leading slash

I can’t rely on this sort of heuristic. It won’t work too often and users will end up with some magic replacement that sometimes works but sometimes does not. That increases confusion, and Fira Code goal always was to decrease confusion.

Sometimes ~ is an unary operator; or used as a home directory.
e.g. I wouldn't want this to render differently:

PATH=~/.local/bin:"$PATH"

Nor this lua 5.3 code (where ~ is unary bitwise NOT):

foo=~bar

Added to ss07

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hatched picture hatched  Β·  3Comments

miniBill picture miniBill  Β·  4Comments

ghivert picture ghivert  Β·  4Comments

alis0nc picture alis0nc  Β·  3Comments

pedrowebcomum picture pedrowebcomum  Β·  4Comments