Wikia

Vim Tips Wiki

Changes: Use a smaller font for vimdiff

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 19: Line 19:
 
" Font must be set in gvimrc
 
" Font must be set in gvimrc
 
let in_diff_mode = 0
 
let in_diff_mode = 0
windo let in_diff_mode = in_diff_mode + &l:diff
+
windo let in_diff_mode = in_diff_mode + &l:diff
 
set guifont=Lucida_Console:h15:cDEFAULT
 
set guifont=Lucida_Console:h15:cDEFAULT
 
" In diff mode
 
" In diff mode
Line 31: Line 31:
 
<pre>
 
<pre>
 
"Here are some settings for diff mode, the colors are troublesome.
 
"Here are some settings for diff mode, the colors are troublesome.
if &amp;diff
+
if &diff
 
set diffopt=filler,iwhite,icase,context:6
 
set diffopt=filler,iwhite,icase,context:6
 
":windo! set wrap
 
":windo! set wrap
Line 47: Line 47:
   
 
----
 
----
Is there any reason not to test for the value of &amp;l:diff directly? In my gvimrc the following lines seem to work:
+
Is there any reason not to test for the value of &l:diff directly? In my gvimrc the following lines seem to work:
   
 
<pre>
 
<pre>
if &amp;l:diff
+
if &l:diff
 
set guifont=Monaco:h9
 
set guifont=Monaco:h9
 
else
 
else

Latest revision as of 09:30, September 29, 2008

Tip 824 Printable Monobook Previous Next

created November 19, 2004 · complexity basic · author Pan Shizhu · version 6.0


I want to change the font when Vim is launched in vimdiff mode, since you'll not be able to change the font later while retaining 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

CommentsEdit

"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

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

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


Around Wikia's network

Random Wiki