TransWikia.com

How can I view a list of all of the features that can be checked for using `has()` in Vim?

Vi and Vim Asked on August 31, 2021

How can I view a list of all of the features that can be checked for using has() in Vim?

I recently came to know the has() function for testing the presence of "features" (see below).

:h features doesn’t show a list of features to test for.

How can I see a list of all features that I can test for using has()?

if has('gui_running')
   set background=dark
   colorscheme codedark
else
"   set termguicolors
   set t_Co=256
   set background=dark
   colorscheme codedark
endif

2 Answers

The documentation in :help has() has a pointer to the features it can check for:

The {feature} argument is a string, case is ignored. See feature-list below.

If you then look at :help feature-list, you'll see it mentions the three kinds of features that can be tested using has():

There are three types of features:

  1. Features that are only supported when they have been enabled when Vim was compiled +feature-list.
  2. Features that are only supported when certain conditions have been met.
  3. Beyond a certain version or at a certain version and including a specific patch. The "patch-7.4.248" feature means that the Vim version is 7.5 or later, or it is version 7.4 and patch 248 was included.

Note that has("gui_running") is the canonical example of a feature of kind 2. Other examples of kind 2 would be has("vim_starting"), has("ttyin") and has("ttyout").

That description of the three kinds of features is followed by a thorough list of features matching kinds 1 and 2. (I won't reproduce it here, you can find it from the linked documentation or, better yet, from the :help system in your copy of Vim or NeoVim.)

See also :help +feature-list, which covers compile-time options that become features (those of kind 1) in more detail, with links to what those features actually enable.

Answered by filbranden on August 31, 2021

You can see a list of these features with :version.

This will show you which is available and which is not, as well as your Vim version, compilation method and other information.

Answered by Biggybi on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP