sponsor Vim development Vim logo Vim Book Ad

basic Tip #824: Choose smaller font in vimdiff mode.

 tip karma   Rating 15/6, Viewed by 1425 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   November 19, 2004 0:04      complexity:   basic
author:   Pan Shizhu      as of Vim:   6.0

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

 rate this tip  Life Changing Helpful Unfulfilling 

<< Add your note files to vim's help system. | Expand #* search to grep-find >>

Additional Notes

mosh at albany, November 20, 2004 18:51
"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
Anonymous, November 26, 2004 1:36
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
[email protected], September 9, 2005 19:02
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
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo