Enabling italics in vim syntax highlighting for mac terminal

I want vim to display my comments in italics, and I understand what I need to post

  cterm = italic 

in

  hi Comment 

in the color.vim file that I am using. This, however, does not affect the text display, which I suspect is associated with some Terminal.app parameter if I do not understand the vim syntax. I would appreciate if anyone could show me how to enable this feature.

In addition, I am currently using a Monaco font that does not have a separate italic file (however, italic syntax highlighting does not work for Consolas, Lucida, Bitstream Vera or other fonts with italic or oblique resolution). Assuming a solution exists for italic fonts, do I need to jump over any further hoops to make it work in Monaco?

Thanks for any input.

EDIT:
I am surprised that I have not yet received an answer; it doesn't look like it should be too hard to do. Maybe this. Alternatively, can someone explain why this is possible not ?

+9
vim terminal syntax-highlighting macos italics
source share
6 answers

As for SnowLeopard, the Terminal does not support the italic attribute (SGR, value 3). Feel free to submit a request at http://bugreporter.apple.com .

Update: Added support for italics in the terminal in macOS Sierra 10.12. Note that the terminfo xterm files included in this version of ncurses do not declare sitm italics. See the vim-specific workaround in Bachmann Eslamis's answer https: //stackoverflow.com/a/16801/... or in cheons answer https://stackoverflow.com/a/16801/../ about the creation of a terminfo file declaring sitm .

+5
source share

MacOS Sierra 10.12 adds support for italics in the terminal (after this question was asked); however, the xterm terminfo files included in this version of ncurses do not declare sitm italics. You can work around this by creating a local terminfo file that declares this feature and inherits the terminfo file that you are currently using.

Use any TERM name in the following instructions. xterm-256color used by default for terminal profiles built into terminals.

Create a file called xterm-256color-italic.terminfo :

 # A xterm-256color based TERMINFO that adds the escape sequences for italic. xterm-256color-italic|xterm with 256 colors and italic, sitm=\E[3m, ritm=\E[23m, use=xterm-256color, 

Run tic xterm-256-italic.terminfo in your terminal, it will generate the file ~/.terminfo/78/xterm-256color-italic . This file will be found by ncurses automatically when a file name is specified for TERM .

To set TERM=xterm-256-italic for a separate terminal profile:

profiles

or you can just replace /usr/share/terminfo/78/xterm-256color with ~/.terminfo/78/xterm-256color-italic

 sudo cp /usr/share/terminfo/78/xterm-256color /usr/share/terminfo/78/xterm-256color-bak sudo cp ~/.terminfo/78/xterm-256-color-italic /usr/share/terminfo/78/xterm-256color 

Then you can find the italic font in vim:

vim

+3
source share

Starting with OS X Sierra 10.12, the terminal application supports italics by default; however, the included version of ncurses contains xterm terminfo files that do not declare support in italics (they do not determine sitm capability). To get around this in Vim, add the following to your vimrc file to define terminal commands for turning on / off italics:

 let &t_ZH="\e[3m" let &t_ZR="\e[23m" 

Then make sure that the font you are using supports italics, and that your color scheme also contains italics for some parts of the syntax. Or, to configure syntax highlighting locally to format comments in italics, add the following to the vimrc file:

 highlight Comment cterm=italic 
+3
source share

Italic support approaches the iTerm2 terminal - in nightly builds. As mentioned in the upgrade request, you need to properly configure TERMINFO var.

+2
source share

Conrad, I donโ€™t know about Terminal.app, but italics are supported in many different terminal emulators. urxvt, konsole, gnome-terminal come to mind.

0
source share

You cannot use the regular monaco font.

Only MacVim seems to allow italics.

Here

0
source share

All Articles