By default, it colors line numbers and statements brown, diffs lightblue and darkblue, completion menus pink, and comments ANSI blue.īecause that’s distracting, Dim uses gray colors for each of these. Although Vim’s default mostly uses relative colors, it uses 8-bit absolute colors for some of its highlight groups. This makes them compatible with 16-color terminals, but also results in consistent colors between terminal utilities.ĭim is based on Vim’s default color scheme. To achieve consistent colors across all terminal utilities without requiring duplicate color settings, 4-bit Vim color schemes like Noctu and Dim exclusively use the first sixteen relative ANSI colors. If the Vim color scheme uses #C31633 as a red color, the terminal theme needs to use that color as the “Red” ANSI color to use that same color in git’s diffs outside of Vim, for example. Then, the terminal emulator needs a theme that uses the same colors as the Vim scheme to customize the relative colors.
First, the Vim color scheme uses an absolute color value for each highlight group. When using Vim inside a terminal emulator, having consistent colors between Vim and the rest of the terminal requires duplicate color settings. These schemes don‘t use any of the named colors, so the terminal’s color preferences don‘t affect them. Unlike other utilities, Vim uses 8-bit or 24-bit color schemes that use absolute colors for each highlight group in an attempt to make the colors look the same for every configuration. The shade is either up to the terminal or the user’s preferences. Setting the precise color values in the terminal emulator’s profile or using a terminal theme allows the utility to mark some output as “yellow”, without having to supply an exact shade.
In Terminal.app, use ⌘+ I to open the Inspector to change the current window’s theme without opening a new terminal window. The color codes from 16 to 255 are used to print 8-bit colors, from which 232 to 255 are grayscale values from black to white. 8-bit and 24-bit ANSI colorīeyond the first sixteen named colors numbered 1 through 16, we arrive in absolute color territory. These colors are configurable in your terminal emulator’s settings, along with the used font and other options. This separates the utility’s intent (“print this error in red”) from the terminal emulator’s styling (“#C31633 is a nice shade of red”). The terminal emulators we use today assign each of these relative named colors with a 24-bit color value. $ echo -e "\033[31mred\033[m" # Prints “red” in red.Īlthough most terminal emulators support at least 256 colors, most utilities use one of the main sixteen colors (black, red, green, yellow, blue, magenta, cyan, white, and a high intensity or bright version of each).įor example, git shows diffs with additions in green and deletions in red, and most testing frameworks print green dots for passed tests and red F’s for failures. Terminal emulators use ANSI escape sequences to–amongst other things like controlling the cursor’s position–read the desired text and background color when printing output. Terminal colors and ANSI escape sequences For example, I don’t configure tmux’s colors, as the green color the terminal theme uses is already a shade I like. The terminal emulator’s theme sets the specific color values instead of hard coding them into the Vim color scheme and relying on true color support.īy using the terminal theme exclusively, all utilities use the same color values. Unlike Vim’s default, it exclusively uses 16 ANSI colors by setting each color to a value between 0 and 15. I’ve been using a customized version of Vim’s default color scheme for the last couple of years. The font is SF Mono, 14pt, with a line spacing of 1.2.
By using Dim as Vim’s color scheme, all color values are set by the terminal theme (showing both dark and light mode). Vim and a git log side by side in tmux in Terminal.app. Doing so results in consistent colors among terminal utilities and a color theme that’s quick to swap out for another one. Instead of configuring colors separately for both Vim and the rest of the terminal, limiting Vim’s color scheme to 16 ANSI colors allows setting all color preferences in the terminal’s theme. Consistent terminal colors with 16-ANSI-color Vim themes Consistent terminal colors with 16-ANSI-color Vim themesīy Jeff Kreeftmeijer on, last updated on