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?
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
As of SnowLeopard, Terminal doesn’t support the italic attribute (SGR, value 3). Feel free to file a request at http://bugreporter.apple.com.
Update: Italic support was added to Terminal in macOS Sierra 10.12. Note that the xterm terminfo files included with that version of ncurses do not declare the italic sitm capability. See the vim-specific workaround in Bahman Eslami’s answer https://stackoverflow.com/a/53625973/754997 or cheon’s answer https://stackoverflow.com/a/48512956/754997 for creating a terminfo file that declares sitm.
Italic support was added to Terminal in macOS Sierra 10.12 (after this question was asked); however, the xterm terminfo files included with that version of ncurses do not declare the italic sitm capability. You can work around this by creating a local terminfo file that declares the capability and inherits whichever terminfo file you’re currently using.
In the following instructions, use whatever name TERM is set to. xterm-256color is the default used by Terminal’s built-in default profiles.
Create a file named 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. This file will be found by ncurses automatically when TERM is set to the file’s name.
To set TERM=xterm-256-italic for an individual Terminal profile:
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:
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.
Here
In my testing, adding set background= or set background=dark or set background=light to one's vimrc file does the trick! Even if I am using the default preinstalled xterm-256color terminfo with no italics information in it! Nothing else works, even if I use xterm-256color-italic suggested in previous answers.
Complete solution, building on top previous answers is:
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
highlight Comment cterm=italic
set background=dark " or set background=light or set background=
I don't know why this is so, have asked a question to Vim devs.
Related
I am using zsh shell on mac terminal, I was playing with oh my zsh theme to jazz a little bit and I have noticed that there are question marks characters around the directory I am in, so my question is how I can remove them? also is there any way to short cut -MacBook-Pro to MBP?
This problem is probably caused by fonts.
I have same problem with my fish shell with tide theme, and I'm struggling now.
However, some question-marks began to display normally in my terminal(still remain some question-marks..), so I hope this will be helpful for you.
Here I share some solutions that may be a hint for you.
Install the Nerd Fonts
https://github.com/ryanoasis/nerd-fonts
Change the font setting from terminal preference.
If you use iTerm2,
check 'Use built-in Powerline glyphs'.
select a font 'for Powerline'. (If you can't see any font for Powerline, you need to install fonts for powerline by googling.)
If you use normal macos terminal,
change the font to any 'for Powerline'
I am trying to set up vim to behave consistently between my Yosemite installation and another Ubuntu 14 system that I have. The main problem I'm having is with background color highlighting. The desired look is below, from gnome-terminal on Ubuntu:
However, when I try to set up the same theme in OSX using iTerm (or terminal.app) I lose the highlighting as vim seems to match the color background to the highlighting background:
Any idea of what I might be doing wrong or some commands I can use to probe how to modify the background color in Macvim so that there is consistency between both interfaces?
Add set t_Co=8 just before the line colorscheme solarized
Typically in Vim, people will have to set t_Co=256 to get rid of the background highlighting you're referring to. However, it seems that MacVim automatically assumes 256 colors, a result of the GUI.
Through set t_Co=8, you'll be overriding that default setting.
In theory anyways?
Some terminals, such as urxvt, support display text in italics via the sitm and ritm terminfo entries:
echo `tput sitm`italics`tput ritm`
I'd like to use this in an application I've got which wants to render real italics into the console. Unfortunately the application is ncurses-based, and ncurses doesn't seem to have a attribute for italics --- it's got a whole bunch, including invisible text (which I'm sure is useful for something), but no italics.
Does anyone know of a way to trick ncurses into displaying italic text, or am I going to have to ditch ncurses and rewrite the program to use raw terminal sequences?
It looks like ncurses 5.10 will contain A_ITALIC. The change went in on September 31 2013:
http://invisible-island.net/ncurses/NEWS-contents.html#t20130831
pdcurses supports A_ITALIC as well so there's at least a vague nod to compatibility. Unfortunately, this won't help me much until 5.10 is released and then becomes widespread...
I'm a fresh vim user, and I want to try new color themes.
I created a .vim dir which contains colors dir with themes and .vimrc file, and I created a symlink in my home dir, it is points to ./vim/.vimrc file.
Here is my .vimrc:
syntax enable
set t_Co=256
set synmaxcol=240
set background=dark
colorscheme twilight
let g:solarized_termcolors=256
This is the screenshot:
and that's what I want:
Whats wrong?
Note:
If I use the graphical macvim, it works, so something wrong with in my terminal
The let g:solarized_termcolors=256 is only useful if you use the solarized colorscheme. Since you want to use twilight, this line is useless and should be removed.
The twilight theme is GUI-only. Its colors are defined with hex values which are only understood by MacVim/GVim. It won't work in the terminal, no matter what you do. You can use twilight256 instead, which is designed for color terminals.
The vim themes, define a separate set of colors for the GUI (i.e. gvim) and the terminal (i.e. vim), hence you might end up seeing different colors in gvim vs vim. The reason behind that is the limited number of colors supported in the terminal compared to GUI.
CSApprox
But you could use a plugin like CSApprox, which will convert the colors in the GUI colorscheme to an equivalent one for terminal such that you see almost the similar set of colors. Most modern terminals (like Gnome Terminal, Console, OSX Terminal) that support 88 or 256 colors should work fine with this plugin.
The good thing about the CSApprox plugin is not separate configuration is necessary, and merely having this plugin in your .vim directory is good enough. And when you run the colorscheme command to choose a color scheme, this plugin automatically converts the colors for you as long as your terminal supports 88 or 256 colors.
And if you're running gvim or the terminal does not support 88/256 colors, this plugin just merely remains silent without doing any color conversions. And there is a mechanism to export the converted colors too I believe.
Alternative
Another similar plugin that I've heard is guicolorscheme which is similar to CSApprox, but you need to set the color scheme using the command :GuiColorScheme <color scheme name>.
Here's what I did:
cp ~/.vim/colors/ir_black.vim /usr/share/vim/vim72/colors/
Then tried to open some code and :colorscheme ir_black
It changes a few colors but makes most of the text start to blink with the cursor.
It happens with almost all the other custom colorschemes as well. Does anyone have any ideas of what might be wrong?
I added t_Co=256 to my .vimrc file and it didn't seem to help.
PS: I'm on a Mac OS X.
Set your TERM to xterm-256color. Follow up on the iterm2 mailing list if that still doesn't work.
Edit : I found an exact duplicate of your question :here. It seems to be an issue with iTerm not supporting 256 colors by default.
The usual problem with color scheme and terminal is that terminal are often limited to 256 colors, and GUI color scheme are using 2^32 colors. So some of them are not correctly rendered in terminal.
There is a simple test to check: if you are lauching the GUI version is the color scheme rendered correctly ?
The possible solution are :
1. Convert your color scheme to 256 colors using the following plugin : CSApprox.vim
2. Choose a different color scheme. (Often on Vim.org color schemes compatible with Terminal have "256" in their name, like "wombat256" for example)
3. Use a GUI version like MacVim or GVim
If I remember correctly, the color sheme Zenburn is working nicely with both GUI and terminal version. It is rather dark with pastel colors.
Personal story : after spending ages to fiddle with color scheme to get something right for terminal, I switched to the GUI version. The GUI version with the icon bar hidden is not really different to terminal version anyway, as long as you are working locally
the default vim binary in /usr/bin/ will not work with any terminal. you need to have a version that supports gui - type "echo has('gui')" in vim command mode to check.
so your only option is to use a gui one (macvim etc.), or compile it with athena, gtk or x11 with macports, but i would advise against the latter, because it pulls down a shitload of dependencies.
i think it's better to use macvim for serious development that needs syntax highlighting, and use the 16 colour version in the terminal for quick edits.