How to set font in GVim


The font used by GVim can be set by choosing Edit -> Select Font, which displays a dialog to pick the font. You can get the same dialog by using the command :set guifont=*

The chosen font is used only for the current session and GVim reverts back to its default font after that.

To set the default font used by GVim, add a command of the form set guifont= to your gvimrc. If you want to add it to vimrc file, then enclose this command in a if has("gui_running") block.

The only tricky part here is, what is the format in which the font and font size should be specified? An easy trick is to set the font and font size in the font dialog and then query it back using :set guifont?. Use the exact value that it displays. Note that the format of the font string varies according to the platform. A Ubuntu Mono font in size 10 is given as Ubuntu Mono:h10 on Windows and as Ubuntu Mono 10 on Linux.

Also on Linux, note that you should not enclose the font string in single or double quotes. If the font string has spaces, then escape them using backslashes. Enclosing in quotes works fine on Windows.

Tried with: Vim 7.4 and Ubuntu 14.04



The default text editor on Ubuntu is GEdit. This is a problem because, unlike Notepad on Windows, GEdit is quite heavy and takes a second or two to start up. A lot of times during work, what I need is a super-simple editor to throw text into, edit it and use as a text buffer between copy and paste. I used to use Notepad for this purpose on Windows. However, editors like GEdit or GVim are too heavy and bloated for this quick-n-dirty usage.

Thankfully, there is Leafpad. This is a very minimal, very light text editor written using GTK. It has the exact same features as Notepad: nothing. So, it starts in an instant whenever I need it and is quick to use and move around. If you need a Notepad replacement on Ubuntu, try Leafpad. If you do not have it, it can be easily installed from the Ubuntu repositories using the package name leafpad.

Tried with: Leafpad and Ubuntu 12.04 LTS

How to enable use of mouse in terminal Vim

The mouse can be used naturally in GVim. But, it would be useful to have some mouse functionality in Vim, running in terminal mode too. For example, to scroll the code or to change the size of split windows. This is a nice feature to have, almost all the time we are using the terminal inside a windowing system anyway.

Thankfully, Vim has functionality built-in to use the mouse in terminal mode. The mouse can be enabled by putting this line in your vimrc file:

set mouse=a

Tried with: Vim 7.3