Vim windows change font

load .vimrc for gvim in windows and change font and colors [duplicate]

Hi. I have just installed vim and want to set some default settings. I have installed gvim here:

C:\Program Files (x86)\Vim\vim73

I have my config file here:

C:\Program Files (x86)\Vim\vim73\.vimrc

I just tried a config file I found. Here is the content of my current .vimrc

From what I understand this should change the default colors

I have added peaksea and it works when I manually change the colors, but I want this to happen automatically. Clearly this does not happen. What have I done wrong?

2 Answers 2

As a first advise: since you’re a starter with VIM, don’t go and copy a .vimrc you find anywhere on the net. They could change the behavior of VIM in a way where nobody can help you if you experience any problems (and don’t understand what’s going on in your .vimrc ).

In general, the settings specific for a GUI version (i.e. GVim ) are stored in a separate file called _gvimrc . The default locations for _vimrc (yes, with underscore, not a dot under Win32) and _gvimrc is C:/Documents and Settings/your_home_folder . Plugins and colorschemes and any other stuff you install should go to a folder called vimfiles on the same location.

Using _vimrc for general settings and _gvimrc for GUI related settings, you avoid the

blocks cluttering up your _vimrc . The _vimrc is getting sourced every time a new instance of Vim is started, afterwards, the _gvimrc gets sourced if it’s a GVim.

set gvim font in .vimrc file

I am using gVim 7.2 on Windows 7. I can set the gui font as Consolas 10 (font size) from the menu. I am trying to set this in .vimrc file like below:

But it doesn’t work. Does anyone know how to set this?

9 Answers 9

I use the following (Uses Consolas size 11 on Windows, Menlo Regular size 14 on Mac OS X and Inconsolata size 12 everywhere else):

Edit: And while you’re at it, you could take a look at Coding Horror’s Programming Fonts blog post.

Читайте также:  Как снимать образ с linux

Edit²: Added MacVim.

/.vimrc file – Jasdeep Khalsa Aug 14 ’13 at 15:21

Try setting your font from the menu and then typing

This should display to you the string that Vim has set this option to. You’ll need to escape any spaces.

I am trying to set this in .vimrc file like below

For GUI specific settings use the .gvimrc instead of .vimrc , which on Windows is either $HOME\_gvimrc or $VIM\_gvimrc .

Check the :help .gvimrc for details. In essence, on start-up VIM reads the .vimrc . After that, if GUI is activated, it also reads the .gvimrc . IOW, all VIM general settings should be kept in .vimrc , all GUI specific things in .gvimrc . (But if you do no use console VIM then you can simply forget about the .vimrc .)

The syntax is wrong. After :set guifont=* you can always check the proper syntax for the font using :set guifont? . VIM Windows syntax is :set guifont=Consolas:h10 . I do not see precise specification for that, though it is mentioned in the :help win32-faq .

How can I change the font size in gVim?

Is there a way to change the size of the font in gVim, using native commands?

And if not, what script can be used to do it quickly?

6 Answers 6

Set the guifont option in your .gvimrc . See :help guifont and :help setting-guifont .

Specifically, you can do something like: set guifont=Consolas:h11 to use 11-point Consolas in gvim on Windows. There are a few other options you can use (each separated with a : ), such as :b for bold, although some of these are only available on certain platforms.

The :h option to set the font size as demonstrated is probably the most useful, and the one specifically related to changing the size of the font, as you requested.

If you want to simply change the font size in a running GVim instance, type:

A window should pop up letting you set font size as well as pick a new font if desired. You can then ask Vim to print the line you would need to add to your

/.gvimrc to make the change permanent:

Produces something like the following in the status line:

Add that with the prefix set to your

Читайте также:  Open with problem in windows

/.gvimrc to persist.

I have the following in my .vimrc to change font size quickly without changing the font. Works on Windows and GTK. I haven’t tested other GUIs. I’m sure I originally copied it from somebody else, but it’s been in my rc file so long I don’t remember where it came from.

Apparently, the way to write the font settings are quite platform-dependent. What worked for me (gvim in MX Linux 17, (a Debian-based Linux distribution with an XFCE desktop)):

  • Determine the current font settings in an open gvim instance using : set guifont?

Example: guifont=DejaVu Sans Mono 12

    Use this information to write the settings (modifying the size as desired) in the

/.gvimrc file, escaping the spaces with backslashes, and not using : before the size.

Example: set guifont=DejaVu\ Sans\ Mono\ 18

    After saving the

/.gvimrc file, new instances of gvim should use the new desired size.

Как я могу изменить размер шрифта в gVim?

Есть ли способ изменить размер шрифта в gVim, используя собственные команды?

А если нет, какой сценарий можно использовать, чтобы сделать это быстро?

Установите guifont опцию в своем .gvimrc . Смотрите :help guifont и :help setting-guifont .

В частности, вы можете сделать что-то вроде: set guifont=Consolas:h11 использовать Консоли в 11 пунктов в gvim на Windows. Есть несколько других опций, которые вы можете использовать (каждый разделен с a : ), например, :b для жирного, хотя некоторые из них доступны только на определенных платформах.

:h Возможность установить размер шрифта , как это демонстрируется, пожалуй, самый полезный, и один непосредственно связанные с изменением размера шрифта, как вы просили.

Если вы хотите просто изменить размер шрифта в работающем экземпляре GVim, введите:

Должно появиться окно, позволяющее установить размер шрифта, а также выбрать новый шрифт при желании. Затем вы можете попросить Vim напечатать строку, которую нужно добавить в свою строку,

/.gvimrc чтобы сделать изменение постоянным:

Создает что-то вроде следующего в строке состояния:

Добавьте это с префиксом set к вашему,

/.gvimrc чтобы сохранить.

В моем .vimrc есть следующее, чтобы быстро изменить размер шрифта без изменения шрифта. Работает на Windows и GTK. Я не тестировал другие графические интерфейсы. Я уверен, что первоначально скопировал это от кого-то еще, но это было в моем файле RC так долго, я не помню, откуда это взялось.

Читайте также:  Wireshark командная строка windows

Видимо, способ написания настроек шрифта довольно зависит от платформы. Что сработало для меня (gvim в MX Linux 17, (дистрибутив Linux на основе Debian с рабочим столом XFCE)):

  • Определите текущие настройки шрифта в открытом экземпляре gvim, используя : set guifont?

Пример: guifont=DejaVu Sans Mono 12

    Используйте эту информацию для записи настроек (изменяя размер по желанию) в

/.gvimrc файле, избегая пробелов с обратной косой чертой и не используя : перед размером .

Пример: set guifont=DejaVu\ Sans\ Mono\ 18

/.gvimrc файла новые экземпляры gvim должны использовать новый желаемый размер.

Vim windows change font

Font manager for Vim

  • List useable fonts
  • Quickly change fonts
  • Quickly change font style and/or size

Only support for Linux and Windows. Does NOT currently support Mac OSX.

Please do help and contribute to fix this 🙂 Please contact me if you have any questions.

This only works in a vim GUI — you can’t set fonts from Vim in terminal

To list avaliable fonts

This will create a new window and display a list of fonts. This may take a second to work out which fonts can be used.

Just hit ENTER on the font you want to use and it will be loaded. Press q to quit the window.

Which will change your font to Dingbats. The font will be autocompleted.

Change size. This command has a helpful autocomplete, suggesting sizes close to the current size.

Now your using size 14 font. Easy.

The last one clears the style. Again it will complete style for you.

Fontmanager also frees up some .vimrc configuration. You can set this in your .vimrc to load a font when you start vim.

This means no more fiddling with escaping with spaces and correcting the format to match your OS. This font will be loaded when fontmanager starts.

To set font size and style easily in your .vimrc .

Font manager stores a cache of the currently available fonts, if a new font is added this cache needs to be updated. Run :FontResetUseableList .

I recommend installing using Vundle:

Add Bundle ‘takac/vim-fontmanager’ to your

  • either within Vim: :BundleInstall
  • or in your shell: vim +BundleInstall +qall

Other Installation Methods

  • Pathogen
  • git clone https://github.com/takac/vim-fontmanager

/.vim/bundle/vim-fontmanager

  • Neobundle
  • NeoBundle ‘takac/vim-fontmanager’
  • Manual
  • Copy the files into your

  • Оцените статью