DEV Community

Cover image for How to Enable Undercurl in Neovim: Terminal and Tmux Setup Guide
Anurag Pramanik
Anurag Pramanik

Posted on

How to Enable Undercurl in Neovim: Terminal and Tmux Setup Guide

If you're using Neovim as your default code editor or IDE, you've likely encountered the concept of undercurl. But what exactly is undercurl? Let's dive in!


What is Undercurl?

Think of the red squiggly lines you see in VS Code to highlight code errors or typos:

vscode errors

Undercurl brings that same functionality to your terminal-based Neovim setup. It's a visual cue for spelling or code errors—right inside your terminal.


Setting Up Undercurl in Neovim (Terminal)

Step 1: Use a True Color Terminal

To enable undercurl, you'll need a True Color Terminal, such as:

To check if your terminal supports undercurl, run the following command:

echo -e "\e[4:3mThis text has an undercurl\e[0m"
Enter fullscreen mode Exit fullscreen mode

If your terminal supports undercurl, you'll see the text undercurled.

undercurl on terminal


Step 2: Enable Undercurl in Neovim

Add the following lines to your Neovim configuration (options.lua or init.vim):

-- Undercurl
vim.cmd([[let &t_Cs = "\e[4:3m"]])
vim.cmd([[let &t_Ce = "\e[4:0m"]])

-- Enable spell check
vim.opt.spell = true
vim.opt.spelllang = { "en_us" }
Enter fullscreen mode Exit fullscreen mode

This setup enables undercurl for spelling errors.

Don't forget to reload neovim after config changes above.

You can see below the word undercurl is undercurled.

undercurl neovim terminal


Step 3: Configure Terminal for Undercurl

If undercurl still doesn’t work, follow these steps:

  • Identify Your Terminal

Run echo $TERM to find your terminal type (e.g., xterm-256color or xterm-ghostty depending on your terminal).

  • Check for Smulx Support

Run:

infocmp -l -x | grep Smulx
Enter fullscreen mode Exit fullscreen mode

If it produces no output, proceed.

  • Generate a Terminfo File
infocmp > /tmp/${TERM}.ti
Enter fullscreen mode Exit fullscreen mode

Replace ${TERM} with your terminal type (e.g., xterm-256color).
Here in this case

infocmp > /tmp/xterm-256color.ti
Enter fullscreen mode Exit fullscreen mode
  • Edit the Terminfo File

Open /tmp/${TERM}.ti in your editor:

nvim /tmp/xterm-256color.ti
Enter fullscreen mode Exit fullscreen mode

Add the following line after smul=\E[4m,:

Smulx=\E[4:%p1%dm,
Enter fullscreen mode Exit fullscreen mode

Smulx entry

  • Reload the Terminfo
tic -x /tmp/${TERM}.ti
Enter fullscreen mode Exit fullscreen mode

Replace ${TERM} with your terminal type which is the output from echo $TERM. Here in this case

tic -x /tmp/xterm-256color.ti
Enter fullscreen mode Exit fullscreen mode
  • Verify Smulx Support Run:
infocmp -l -x | grep Smulx
Enter fullscreen mode Exit fullscreen mode

You should now see output confirming Smulx.

infocmp entry

Open Neovim and enjoy undercurl support for spelling and code errors.

neovim with undercurl from terminal


BTW, if you love my neovim and tmux setup above, do check my dotfiles on GitHub.


Enabling Undercurl in Neovim with Tmux

Undercurl may not work out of the box in Tmux. Here’s how to fix that:

Step 1: Update Your tmux.conf

Add the following lines to your ~/.tmux.conf or ~/.config/tmux/tmux.conf:

set -g default-terminal "screen-256color"

# Undercurl support
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
Enter fullscreen mode Exit fullscreen mode

Check if you are able to see undercurl in Neovim inside tmux session. If not follow the below steps.

Step 2: Configure the Terminfo

  • Run echo $TERM (should return screen-256color).
  • Follow the terminal configuration steps. Remember your $TERM is now screen-256color so replace ${TERM} with screen-256color from step 3 onwards.

Step 3: Verify Smulx in Tmux

Run:

infocmp -l -x | grep Smulx
Enter fullscreen mode Exit fullscreen mode

If successful, you’ll see the correct Smulx configuration.

infocmp within tmux

Step 4: Test Undercurl in Tmux

Open Neovim inside a Tmux session, and voilà! Undercurl now works in Neovim + Tmux.

neovim undercurl within tmux


With these steps, you've unlocked the power of undercurl in Neovim, both in standalone terminals and Tmux sessions. Happy coding!


Questions or Feedback?

Feel free to leave a comment or ask any questions if you have doubts! I’d love to hear your thoughts or help you out. 😊

Top comments (0)