Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling italics in vim syntax highlighting for mac terminal

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?

like image 863
daltonb Avatar asked Aug 25 '09 09:08

daltonb


1 Answers

As of OS X Sierra 10.12, the default terminal app supports italics; however, the included version of ncurses contains xterm terminfo files that do not declare italic support (they do not define the sitm capability). To work around this in Vim, add the following to your vimrc file to define the terminal commands for enabling/disabling italics:

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. Or, to customize the syntax highlighting locally to format comments in italics, add the following to your vimrc file:

highlight Comment cterm=italic
like image 199
Bahman Eslami Avatar answered Oct 14 '22 12:10

Bahman Eslami