Skip to main content
edited body
Source Link
Christian Brabandt
  • 26.5k
  • 1
  • 54
  • 80

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="CTRLR=guifont?=&guifontEnter"

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="CTRLR=guifont?Enter"

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="CTRLR=&guifontEnter"

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.

added 6 characters in body
Source Link
D. Ben Knoble
  • 27.7k
  • 3
  • 31
  • 68

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="let &guifont="CTRLR=guifont?=guifont?Enter""

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="CTRLR=guifont?Enter"

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="CTRLR=guifont?Enter"

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.

Source Link
Christian Brabandt
  • 26.5k
  • 1
  • 54
  • 80

Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:

:set guifont=*

This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.

Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.

Once you are satisfied one needs to store that particular font in either the vimrc or gvimrc init file.

So to make this setting permanent, I edit the initialization file:

:e $MYVIMRC

and then I put the guifont setting there by typing this:

ilet &guifont="CTRLR=guifont?Enter"

This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.

So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.

Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.

Here is an example of mine that I use on various systems:

if has("autocmd")
  function! SetGuiFont()
    if has("gui_gtk") && !(has("win32") || has("win64"))
      let &guifont="Ubuntu Mono derivative Powerline 12"
    elseif has("win32") || has("win64")
      try
        let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
      catch
        " font does not exists, fall back to default
        let &guifont="Courier_New:h10:cANSI"
      endtry
    " optionally: add statements for other guis
    endif
  endfunction

  if !exists('#VimStartup#GuiEnter')
    augroup VimStartup
      au!
      autocmd GuiEnter * :call SetGuiFont()
    augroup end
  endif
endif

You can make this of course a lot more complex, depending on your needs.