Language: EN

como-usar-ligaduras-en-visual-studio-code

How to use ligatures in Visual Studio Code

Ligatures are a relatively new feature in programming environments. They are alternative symbols that represent combinations of common characters in the code.

For example, instead of seeing >= or ==, with ligatures, you will see special symbols like , , or that combine these characters into a single visual representation.

vscode-ligatures

Ligatures provide functionality, but above all aesthetic improvement in your development environment. We could argue whether they improve code readability (in theory, yes) but, in any case, they are “cool” and can enhance your programming experience.

These ligatures are not only pleasing to the eye, but they also facilitate reading and improve error detection in your code.

So let’s see how to enable ligatures in the Visual Studio Code development environment.

How to Use Ligatures in Visual Studio Code

To activate ligatures in Visual Studio Code, you first need a compatible font. Nerd fonts are popular for this purpose, as they include specific glyphs for ligatures.

You can download these fonts from Nerd Fonts.

Everyone will prefer their font. I personally really like Inconsolata NF. Other popular options are Fira or VictorMono. It’s best to check the different fonts and choose the one you prefer.

Configuration in Visual Studio Code

Once you have downloaded and installed a Nerd font, follow these steps to configure ligatures in Visual Studio Code:

  1. Open Visual Studio Code
  2. Go to the settings menu by clicking “File” and selecting “Preferences,” then “Settings.”
  3. In the search bar, type “font family” to search for the font family setting.
  4. In the “Editor: Font Family” setting, enter the name of your font. For example, this is how it would look for the Inconsolata NF
Inconsolata NF, Consolas, 'Courier New', monospace

In theory, it should work for you. But, in general, I prefer to edit the options JSON file directly.

In VSCode, there is a button in the options window that allows us to open the settings.json file directly in a simple way.

In this file, verify that you have these lines:

"editor.fontFamily": "Inconsolata NF, Consolas, 'Courier New', monospace"
"editor.fontLigatures": true

If you also want to use this font in the integrated editor, add these lines.

"terminal.integrated.fontFamily": "Inconsolata NF",   
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.inheritEnv": false,

Save the settings.json file. and you’re done! Now, Visual Studio Code will use the Nerd font with ligatures in your development environment.

Font Variations and editor.ligatures Parameter

Some Nerd fonts support ligature variations. These are options that allow us to adapt some of the visual parameters of the fonts. For example, the font Fira stands out for having a large number of options to customize the appearance.

fira-font-ligatures

If you want to customize your ligatures, you can use the editor.ligatures parameter in Visual Studio Code. This parameter allows you to enable or disable ligatures according to your preferences.

To configure this parameter, in the configuration file, add the font options.

"editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'zero', 'cv02', 'cv29', 'ss08'",

Font variations and the ability to enable or disable ligatures provide a high degree of customization so that you can adapt Visual Studio Code to your specific needs.