Custom Fonts in VIM - vim

I'm somewhat new to vim and wanted to add some custom fonts.
This is the one I wanted to add: https://github.com/belluzj/fantasque-sans.
How would I tell vim to use this font since it's not part of the default font set.
Do I add this to the .vimrc?
I'm on Mac Catalina by the way.

If you're using vim in the command line: Vim uses the font of your terminal emulator so if you set up your terminal emulator (iTerm2, Terminal.app etc) to use that font it should pick it up automatically.
If you want that font to be used exclusively in vim and you're using gvim you can change the guifont option which is documented on the Vim FAQ:
"You can change the 'guifont' option to change the font used by GUI Vim. To
display the current value of this option, you can use
:set guifont?
You can add the displayed font name to the .vimrc file to use the font
across Vim sessions. For example, add the following line to the .vimrc file
to use Andale Mono font.
set guifont=Andale_Mono:h10:cANSI
For Win32, GTK and Photon version of Vim, you can use the following command
to bringup a dialog which will help you in changing the guifont:
:set guifont=*
You can also use the -font Vim command line option to specify the font used
for normal text."

Related

Vim opening terminal with different profile than the default

I 'm working on MacOS Catalina and I am using vim 8.2
The only profile set up in my iterm2 is the Default one.
which has been set up to used a slightly customized solarized theme as depicted below
I am now opening vim (which has also been set up to use its counterpart solarized colorscheme)
My question is, why when I am opening the :terminal in vim, this opens in black background (I don't think there even exists a profile with such setting)
This will happen when you have Vim running with 'termguicolors' on. (You can confirm it and see where it's being enabled with :verb set tgc?.) Same as when running in a GUI (not the terminal), it will tell Vim to use 24-bit colors, and use the color scheme full RGB color specifications, rather than use the terminal color palette.
In that situations, Vim's colors get completely detached from those of the terminal where Vim is running, so Vim's built-in terminal no longer has access to the actual terminal colors.
You can set specific colors to use in Vim's built-in terminal with the g:terminal_ansi_colors variable (see :help g:terminal_ansi_colors for details.)
Alternatively, disabling 'termguicolors' should work as well. Assuming the Vim color scheme has been built in a way that will use the terminal color scheme to reproduce the same colors, it might not have other side effects in how Vim colors otherwise look.
Removing line
set termguicolors
from .vimrc fixed it

Fail to set font in Macvim

I am configuring macvim on Mac OS X Mavericks. I type "set guifont=Menlo\ 14" in both ~/.vimrc and ~/.gvimrc but the editor remains displaying in courier.
I insert ":set guifont?" and it reveals "guifont=Menlo\ 14". I overviewed the content of .vimrc and .gvimrc but found no other line overriding the guifont setting.
I have checked several posts in stack overflow but cannot yet find the solution. Wish to get some help, thanks for anticipation.
The ideal way of going about doing this is by invoking the following command from vim :
set guifont=*
That will open a font selection dialog box and you can select whatever you would like there. Once done, you should then check what the option was set to by using the command you mentioned yourself :
set guifont?
Now you should put the output of that in your .gvimrc (not .vimrc) and additionally you'll need to escape the spaces like you're doing already. There might be subtle mistakes in what you're setting yourself, the font size for instance can sometimes be set in different ways.
On my version of MacVim (7.4.258) and running EL Kapitan, putting
set guifont=*
in .vimrc caused MacVim to spit out the following error (when run from the command line, starting it from the Dock caused it to just not run at all):
E665: Cannot start GUI, no valid font found
So it seems the correct way is to start MacVim, use the Edit > Font > Show Font menu, pick a font, then use
set guifont?
to find the line to add to your .vimrc
Also remember to use forward slashes to escape any spaces in the font name.
To change font, use Edit -> Font -> Show Fonts and selected a font.
Unfortunately this setting gets wiped out with each update of MacVim.
To have your font setting persisted in MacVim add this to your ~/.gvimrc
set guifont=Hack\ Nerd\ Font:h12

How to set font to be DejaVu Sans Mono in vim for xp?

i have installed vim for xp ,there is a file _vimrcin C:\Vim ,i have set font in _vimrc :
set guifont=Bitstream_Vera_Sans_Mono:h11:cANSI
when i open vim ,the setup can not work ,when i open gvim ,the setup can work .
what is the matter?
the configuration i write in _vimrc can work perfectly in gvim when i open it ,why it can not work in vim?
In my gvim and cmd ,i can see Bitstream_Vera_Sans_Mono font in screen ,and my active console code page is set to be 437, vim can't use Bitstream_Vera_Sans_Mono font ,why?
In $MYVIMRC, add the line:
set guifont=DejaVu\ Sans\ Mono:h11
...where :h11, specifies a height of 11 points.
N.B: A _ can be used in the place of a space, so you don't need to use
backslashes to escape the spaces.
Reference
:help 'guifont'
Notes, following update to question
'guifont' only works on Vim's GUI (i.e. gvim) and not on a console (or terminal) vim instance. Vim has no control over the font of the terminal in which it is running.
If you wish to change the Windows XP(!) console font, see How to change the Windows XP console font? on SuperUser.

gvim color scheme to match vim in xterm

I've the same question as Change GVim Color Scheme to be Like Command Line Vim
I specially like the 'darkblue' scheme on vim (through putty). Can there be some script which changes the darblue color scheme and changes the guibg and guifg to match the values in ctermbg and ctermfg.
First you must be aware, maybe you are, that most terminal emulators come with the ability to let the user define a 16 colors default palette. If 256 colors support is not activated explicitely, most - if not all - terminal emulators will default to those 16 colors.
Because each terminal emulator comes with its own default colors and those can be modified by the user there's no way to tell the value of DarkRed or even Black without actually looking at the configuration file or preferences window of your terminal emulator.
Assuming that you are not running in 256 colors mode, you should find where the default/custom colors are defined in your terminal emulator and note their hexadecimal value.
Here is my own colorscheme, in Gnome terminal:
Once you have all the values, you can make a copy of the colorscheme:
$ cp /usr/share/vim/vim7x/colors/darkblue.vim ~/.vim/colors/darkblue.vim
and change all the guibg and guifg to the values you noted earlier.
Good luck.
Vivify provides colorschemes that usually support both terminal vim and gvim. Try downloading your scheme there.
you can use this way...
:colorscheme darkblue
this is worked in the gvim and xterm.
if you want to change the command line vim you can use this method.
this is same like as the gvim.
first you can type :colorscheme then press the tab it will give more color scheme.
which you you can set.
Instead of trying to downgrade the GVIM colors to the limited set of terminal colors, I would (assuming you have a "modern" terminal emulator that supports 256 colors) use the CSApprox plugin to get a very close rendition of the GVIM colors in the console, i.e. upgrade the terminal colors.
I'm surprised this isn't up here. There's a plugin called csapprox that does exactly this. The coolest thing is that it does it with no configuration. Just set your colorscheme in your vimrc and it automatically loads the colors correctly in terminal vim. Add it to Vundle:
Bundle 'godlygeek/csapprox'
And restart Vim. The only issue I've found is that sourcing your vimrc breaks it. You'll have to restart vim every time you want to source the vimrc with :so ~/.vimrc.

Using Vim warning style in gVim

When for example an edited file is changed outside of Vim, Vim issues a warning and offers to reload the file. In command line Vim a green text on the bottom appears, but in gVim there is a GTK+ popup window instead. I like Vim behaviour more, and I'd like to have it in gVim as well, how can I change that?
There is an option to enable that behavior in the GUI version of Vim. If c
is set in guioptions, console-like dialogs are used instead of graphical
popup ones.
:set guioptions+=c

Resources