Karl SvenssonBlogLinkedIn

Setting up gVim

Written 2020-09-14 by Kalle
2 min read | 304 words

When installing gVim on my Windows PC at work, I discovered some nuisances with the default settings. This post contains my changes to the _vimrc file which sets things right.

Indentation

I want my indents to consist of two spaces. To acheive this, add the following to the _vimrc file (the comments are pasted from Vim Fandom):

set expandtab " insert space characters whenever the tab key is pressed
set tabstop=2 " control the number of space characters that will be inserted when the tab key is pressed
set shiftwidth=2 " the number of space characters inserted for (automatic) indentation

Font

The default font of gVim looks ... old. Instead, I wanted to use JetBrains Mono. I changed it by clicking Edit -> Select Font... and selecting my font. The change was not persistent, however, so the procedure had to be repeated everytime I opened a new window.

The fix is described by Steve Litt at Troubleshooters.com:

  1. Select the new font with the procedure above.
  2. Enter the command :set gfn?.
  3. Copy the font information which is displayed in the command area. For instance guifont=Terminal Bold 12.
  4. Add the following to the _vimrc file: set gfn=Terminal Bold 12 (with corresponding info for your font).

Window jumping

When changing tabs, opening new files etc. the entire gVim window would jump around the screen. According to this StackOverflow post:

This happens because when vertical splitting the window, vim needs to add a vertical scrollbar, which causes vim to recalculate the visual size and eventually makes vim jump to a different screen location.

The fix is to add the following three lines to the _vimrc file:

set guioptions-=r " disable the right scrollbar
set guioptions-=L " disable the left scrollbar
set guioptions+=k " disable Vim resizing

© 2024