Enabling italics in vim syntax highlighting for mac terminal
-
19-09-2019 - |
Question
I'd like to have vim display my comments in italics, and I understand I need to place
cterm=italic
in the
hi Comment
line in the color.vim file I'm using. This, however, is having no effect on the text display, which I suspect has to do with some Terminal.app setting, unless I'm misunderstanding the vim syntax. I'd appreciate if someone can show me how to enable this feature.
Additionally, I am currently using the Monaco font, which does not have a separate italic file (however, the italic syntax-highlighting doesn't work for Consolas, Lucida, Bitstream Vera or other italic- or oblique-enabled fonts either). Assuming that a solution exists for fonts with italics, do I have to jump through any further hoops to get Monaco working?
Thanks for any input.
EDIT:
I'm surprised I haven't gotten an answer yet; this doesn't seem like it should be too difficult to do. Maybe it is. Alternatively, could someone explain why this would not be possible?
Solution
As of SnowLeopard, Terminal.app doesn’t support the italic attribute (SGR, value 3). Feel free to file a request at http://bugreporter.apple.com.
OTHER TIPS
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 a file ~/.terminfo/78/xterm-256color-italic
, then you can set TERM=xterm-256-italic
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 italics font in vim:
As of OS X Sierra, the default terminal app supports Italics. All you need to do is to add the following to your vimrc file:
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
Then make sure the font you use supports italics and also your colorscheme contains italic for some syntax parts.
Italics support is coming to the iTerm2 terminal app - it's in the nightly builds now. As mentioned in the enhancement request you need to configure the TERMINFO var correctly.
Konrad, don't know about Terminal.app, but italic is supported in a lot of different terminal emulators. urxvt, konsole, gnome-terminal come to mind.
You can't with the regular monaco-font it seems.
It seems that only MacVim enables the italics.