Why MacVim does not display some fonts properly? - vim

OS: Mac OS X 10.10.3
MacVim: 7.4.712
I am trying to use MacVim to write LaTeX instead of Sublime Text.
So I set the font "Lucida Grande" from menu of MacVim but it looked strange:
This is what Lucida Grande looks like in Sublime Text:
Then I set "Helvetica" in MacVim and it looks like:
It seems that MacVim tries to display fonts in mono but this is not what I want. How could I set the font properly in MacVim just like what Sublime Text does?

While GVIM / MacVim can use proportional fonts (on certain platforms), there's no way around the screen-cell based addressing in Vim; it's a fundamental concept (taken from the terminal), and many features (like blockwise selections) depend on it.
So, you have to live with the fact that an i will take as much horizontal space as a W, and choose a corresponding (monospaced) font accordingly. This way, your editor will look much better :-)

Related

gvim font too wide on docker container

Why does gvim guifont look too wide, or "interfont" space too wide, regardless of which one I choose?
Instead of looking like this:
It looks like this:
What I've tried
I checked the installed fonts into the docker container:
$ fc-list | grep -i light
/usr/share/fonts/dejavu/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
$
Then I try such font on gvim:
But it still looks wider than the . Same thing if I try with another font.
So, what do I need to do to make it look like the first screenshot?
Where to start?
In the first screenshot, the name of the font in use is clearly visible: Inconsolata. If you want another GVim to look like that one, you will rather obviously need the same font. If you don't have it, then install it.
As for why your attempts were unsuccessful… fonts basically exist in two kinds:
"Variable-width", where each glyph has its own metrics and the spacing between two glyphs can also be adjusted on a case-by-case basis.
These fonts are optimised for reading in a natural way, where your eyes follow the horizontal flow of the text. They are the default fonts used in word processors, web pages, or books.
"Fixed-width" (or "monospaced"), where all glyphs have the exact same metrics and no attempt is made to adjust spacing between glyphs.
These fonts are optimised for being displayed in a grid, with each glyph perfectly aligned horizontally and vertically with the others, allowing your eyes to process text in both directions, following alignments, patterns, etc. They are the default fonts used in terminal emulators and programming text editors/IDEs.
GVim being nothing more than a glorified and extremely specialised terminal emulator, it only knows how to display text in a grid so it only really works with monospaced fonts like Inconsolata. Tell it to use a variable-width font and you get a mess.
DejaVu Sans being a variable-width font, you get the only possible outcome. If you choose Monospace from that font chooser you should get a usable, at least, setup.

Use arbitrary colors in Vim and terminator

I am working on terminal Vim colorscheme (for 256-color terminal) and I need a few dark colours that I could use as backgrounds. I'm not satisfied with ones available in standard palette - for example, color 22 (#005f00), the darkest shade of green, is still too bright.
I've read that terminal Vim does not allow specifying colors as RGB, so - to get arbitrary colors - I would have to tweak terminal emulator's color palette. Is there a way to tweak full 256-color palette in gnome-terminal / terminator? Preferences window only allows editing basic 16.
BTW, Chrome's hterm allows this via 'color-palette-overrides' preference (but has its own drawbacks).
Gnome-terminal doesn't offer a UI to alter the colors (apart from the first 16), but you can use escape sequences, e.g.:
echo -ne '\e]4;22;#004f00\a'
As you've mentioned, sometimes these colors get reset to their default values. This was a bug in the underlying VTE library, and got fixed in version 0.36.
As far as I know, you won't find a single terminal emulator that gives you that kind of control over the whole standardized xterm palette.
So, if you ever intend to share that colorscheme you are stuck with the default palette.
On the other hand, if that colorscheme is only meant for your usage or if you are OK with forcing a hard dependency on your users, you can use japh's colorcoke to generate an alternate palette more suited to your needs. See the repo's wiki for examples)

List of fonts available in gvim

I know I can set fonts for gvim using something like set guifont=Menlo\ Regular:h14. I have the following questions
Is there a wiki where I can see what all fonts are supported?
I want to set my font to "Lucida Sans Typewriter". I tried set guifont=Lucida Sans Typewriter\ Regular:h14, but it gave me an error when I opened a file using gvim. Error is "E518: Unknown option: Sans"
I also tried to increase the font size using set guifont=Sans\ Regular:h14, but looks like it is stuck at font size 11. I am trying this on macvim.
You need to backslash all of the spaces in the font name, not just the last one.
You can :set guifont=* to open a font chooser with the fonts available on your system. Then after you pick one you like you can :set guifont? to read back the value you need to put in your .vimrc.

How to remove border around terminal vim

I'm using terminal vim with the solarized-light theme for both vim and my terminal. If I try and use for example a dark colour scheme for my terminal a dark border appears around my vim window as shown in the image below.
Is there a setting I can change to remove this border, or reduce its width to 0?
You can't do that from Vim and your terminal emulator doesn't expose an option for that either.
So… use the same background color.
Nothing to do with vim it's a terminal background. There's no simple solution. Use the same background color or change a font. Some fonts with certain sizes ideally fit into terminal width and height. Bitstream font works for me.

color issue with VIM and iTerm2

I have a color issue on iTerm 2 (both stable and beta release) using VIM (last version).
This is a screenshot on iTerm 2 using vim-css-color plugin :
And the same on the Terminal.app :
As you can see, iTerm renders quite strange colors (and not only with this plugin, this is just an example). I've been playing with the contrast slider in iTerm2 prefererences and every Vim parameter i found so far (x-term-color-256, etc etc).
This is my .vimrc file : https://github.com/nanark/.vim/blob/master/vimrc
Any idea ?
A terminal with 256 color support (like iTerm 2) is simply not capable of displaying the full range of colors.
The css plugin uses a conversion to approximate the hex color code in the terminal. This was designed to work with the default set of colors used by xterm based on the comments in the code.
If you want an accurate preview, you should use gvim or macvim.

Resources