List

What are Ligature Fonts?

To quote the Fira Code README:

Problem

Programmers use a lot of symbols, often encoded with several characters. For the human brain, sequences like ->, <= or := are single logical tokens, even if they take two or three characters on the screen. Your eye spends a non-zero amount of energy to scan, parse and join multiple characters into a single logical one. Ideally, all programming languages should be designed with full-fledged Unicode symbols for operators, but that’s not the case yet.

Solution

Fira Code is a free monospaced font containing ligatures for common programming multi-character combinations. This is just a font rendering feature: underlying code remains ASCII-compatible. This helps to read and understand code faster. For some frequent sequences like .. or //, ligatures allow us to correct spacing.

Here are some of my favorite Fira Code ligatures for R.

Assignment operators

x <- 10 becomes

23 -> y becomes

Relational operators

x <= y becomes

x >= y becomes

x == y becomes

x != y becomes

Native pipe operator

x |> sqrt() becomes


Step 1: Install the Fira Code Font Family

Windows

a) Go to https://github.com/tonsky/FiraCode/releases/latest
b) Download the Fira_Code_vX.X.zip file
c) Extract all the zipped files to a folder on your computer
d) Open the extracted folder and open the ttf subfolder
e) Highlight all files in the tff subfolder
f) Right-click on one of these highlighted files to open the context menu
g) Select “Install” from the context menu

MacOS

  • Follow the same instructions 1(a) to 1(f) from Windows
  • Select “Open” or “Open with Font Book” from the context menu
  • Select “Install Font”

Linux

Animation showing how to install the Fira Code font family on Windows


Step 2: Change the RStudio Editor Font

a. In RStudio, open the “Tools” menu and select “Global Options…”

b. Select the “Appearance” tab and change the “Editor Font” to Fira Code.

c. Click the “OK” button.

Animation showing how to change the RStudio Editor Font to Fira Code


Step 3: Using Ligatures in RStudio

Now, certain character combinations will automatically be transformed into beautiful ligatures as you type them. The best part is that, although the ligatures may appear to be one character, they are still represented in your files as the individual characters and thus can still be edited without problem.

Animation showing the use of ligatures in RStudio


RStudio Screenshots taken using Windows version 2022.02.3+492 “Prairie Trillium”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Posts

1 2
June 27th, 2022

Using Fira Code Ligatures in RStudio

What are Ligature Fonts? To quote the Fira Code README: Problem Programmers use a lot of symbols, often encoded with […]

June 12th, 2021

Slides from Run Linux R on Windows 10

Presentation to the Kansas City R Users Groups I will talk about using the Linux version of RStudio Server on […]

June 2nd, 2021

A Conceptual Introduction to Machine Learning

Presentation to the Northwestern University Department of Psychology Whereas the classic statistical methods (i.e., inferential models) traditionally used in the […]

August 16th, 2020

Running RStudio Server via Ubuntu 20 on Windows 10

Here is a super-easy visual guide to setting up and running RStudio Server for Ubuntu 20 on Windows 10. This […]

July 10th, 2020

Row-wise means in dplyr

This is a tutorial on calculating row-wise means using the dplyr package in R

February 22nd, 2019

Exploring movie lengths using R

To show off how R can help you explore interesting and even fun questions using data that is freely available […]

January 5th, 2019

Statistical Rethinking: Chapter 7 Practice

Here I work through the practice questions in Chapter 7, “Interactions,” of Statistical Rethinking (McElreath, 2016). I do my best […]

December 31st, 2018

Statistical Rethinking: Chapter 6 Practice

Here I work through the practice questions in Chapter 6, “Overfitting, Regularization, and Information Criteria,” of Statistical Rethinking (McElreath, 2016). […]

December 27th, 2018

Statistical Rethinking: Chapter 5 Practice

Here I work through the practice questions in Chapter 5, “Multivariate Linear Models,” of Statistical Rethinking (McElreath, 2016). I do […]

December 26th, 2018

Statistical Rethinking: Chapter 4 Practice

Here I work through the practice questions in Chapter 4, “Linear Models,” of Statistical Rethinking (McElreath, 2016). I do my […]