You are not logged in.

#1 2012-10-30 11:52:41

Pascal C.Plusplus
Member
From: France
Registered: 2012-09-27
Posts: 17

[SOLVED] Vim : cterm=italic doesn't work

I tried to change the colorscheme in Vim to have comments in italic like this :

hi Comment guifg=#7C7C7C guibg=NONE gui=NONE ctermfg=gray ctermbg=NONE cterm=ITALIC

But this make the comments' color inverted, which is very ugly, and they are not in italic.
I'm using urxvt with the font DejaVu Sans Mono, but I think the problem comes from Vim because I can print italic text in the terminal.
Does someone know if it is possible to fix it ? Thank you !

Last edited by Pascal C.Plusplus (2012-10-30 18:59:45)

Offline

#2 2012-10-30 12:07:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,052
Website

Re: [SOLVED] Vim : cterm=italic doesn't work

EDIT: Nevermind the following, I get the same problem you do with that highlight command.  I do have italics in vim though, so I suspect something may be wrong with that highlight command.  EDIT2: perhaps I only have italics on my other computer - sorry for potential misinformation - I'll check my other computer in a bit and hopefully I'll have more useful input.

Do you set the TERM environment variable outside of vim (eg in ~/.bashrc)?  If so, remove it.

Do you set the "term" variable in ~/.vimrc?  If not, add it as follows:

set term=screen-256color

Last edited by Trilby (2012-10-30 12:11:51)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-10-30 12:17:50

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] Vim : cterm=italic doesn't work

Are you using a terminal multiplexer, e.g. tmux?


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#4 2012-10-30 12:57:38

Pascal C.Plusplus
Member
From: France
Registered: 2012-09-27
Posts: 17

Re: [SOLVED] Vim : cterm=italic doesn't work

I use tmux, but the problem appears both in and out of tmux.

Offline

#5 2012-10-30 13:53:30

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] Vim : cterm=italic doesn't work

If the problem is present outside tmux, then you haven't defined font variants your terminal is supposed to use, e.g.

URxvt.font:xft:DejaVu Sans Mono:style=Book:pixelsize=13
URxvt.boldFont:xft:DejaVu Sans Mono:style=Bold:pixelsize=13
URxvt.italicFont:xft:DejaVu Sans Mono:style=Oblique:pixelsize=13
URxvt.boldItalicFont:xft:DejaVu Sans Mono:style=Bold Oblique:pixelsize=13

With the above, things should work as you wish in a bare urxvt session.

With tmux, however, the case looks differently and depends on the screen-256color terminal definition. There appear to be ways to work around the issue, though personally I'm happy with a regular font and slightly darker fg color for all the comments.


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#6 2012-10-30 15:06:05

Pascal C.Plusplus
Member
From: France
Registered: 2012-09-27
Posts: 17

Re: [SOLVED] Vim : cterm=italic doesn't work

I have already defined font variants, and it didn't work. I dont think that the font is the problem, because I am able to print italic text with

echo -e "\e[3mitalic\e[m"

Offline

#7 2012-10-30 15:10:47

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] Vim : cterm=italic doesn't work

Did you run

xrdb -load ~/.Xresources

afterwards? Maybe your config file isn't sourced properly?


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#8 2012-10-30 16:16:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,052
Website

Re: [SOLVED] Vim : cterm=italic doesn't work

I just got to my other computer and italics work properly on this one.  The only difference I could find between this (work) computer and my home computer is in the vimrc I do not set a term variable.

I tried setting the term variable in my vimrc and it replicated the problem, removing this fixed it again.  So in contrast to my earlier incorrect suggestion, have you tried removing and "set term=..." commands from your vimrc?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2012-10-30 18:58:29

Pascal C.Plusplus
Member
From: France
Registered: 2012-09-27
Posts: 17

Re: [SOLVED] Vim : cterm=italic doesn't work

Trilby : Thank you, now it works ! I just had to remove the "set term=..." line in my .vimrc and to set the TERM variable to rxvt-unicode-256color.

Offline

Board footer

Powered by FluxBB