Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #824 - Use a smaller font for vimdiff

Created: November 19, 2004 0:04 Complexity: basic Author: Pan Shizhu Version: 6.0 Karma: 15/6 Imported from: Tip#824

Recently someone wants me to post the solutions of this.


I just want to change the font when vim is launched in vimdiff mode, since you'll not be able to change the font later while retain the 1:1 split, (in other cases, I can change the font before :diffs)


Just add something like the following in .gvimrc:


Of course, your fonts may vary.



" Font must be set in .gvimrc

let in_diff_mode = 0

windo let in_diff_mode = in_diff_mode + &l:diff

set guifont=Lucida_Console:h15:cDEFAULT 


" In diff mode 
if in_diff_mode == 1 
set guifont=isi_ansi:h14:cDEFAULT 
endif 


unlet in_diff_mode

Comments

"Here are some settings for diff mode, the colors are troublesome. if &diff

:set diffopt=filler,iwhite,icase,context:6 
":windo! set wrap 
" hi diffchange ctermbg=0 .. is black on unix 
:hi diffchange term=NONE ctermbg=3 ctermfg=5 
:hi diffdelete term=NONE ctermbg=0 
:hi diffadd term=NONE ctermbg=1 ctermfg=15 
if $TERM =~ "xterm" 
:hi diffchange ctermbg=8 ctermfg=1 
:hi difftext ctermbg=8 ctermfg=7 
:hi diffadd ctermbg=8 ctermfg=11 
endif 

endif


mosh at albany , November 20, 2004 18:51


Nice Tip! But is there any reason not to test for the value of &l:diff directly? In my .gvimrc the following lines seem to work:

if &l:diff 
set guifont=Monaco:h9 
else 
set guifont=Monaco:h11 
endif 


Anonymous , November 26, 2004 1:36


Thank you, I have been looking for information on how to set the font size to much larger on a MacOSX installation of Vim.app.

This worked finally:

set guifont=Monaco:h18

bobsavage--AT--mac.com , September 9, 2005 19:02


Advertisement