Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to check if a feature has been compiled IN:

:echo has("syntax")

How do I get a list of all possible compile-time features?

Example (pseudo-code):

foreach "feature" in "feature-list":
    print "has(feature)"

Objective: build a vim plug-in for self use that detects some features and "switches" on some conditions.

share|improve this question

Objective: build a vim plug-in for self use that detects some features and "switches" on some conditions.

If you "switch" on some features, you still need to know them beforehand. What's so bad about hard-coding their names directly into the plugin?!

Vim has limited capabilities for self-reflection. You could parse the output of :version (which includes a feature list). I've also seen a plugin parse a particular help page (e.g. $VIMRUNTIME/doc/options.txt) to obtain a list of settings, but I would recommend none of them if you don't need them.

share|improve this answer
That's right. :version is what I am "reflecting" on at the moment, but it's a hack.. ideally one would get a dictionary where keys are 'browse', 'wildmenu', 'X11', etc.. and values are 0 || 1 ! – Robottinosino Feb 1 '13 at 11:16
Do you have a valid use case? Why doesn't hard-coding suit you? – Ingo Karkat Feb 1 '13 at 11:21

This is a list of possible features in my version of Vim (7.3.315):

["all_builtin_terms", "amiga", "arabic", "arp", "autocmd", "balloon_eval", "balloon_multiline", "beos", "browse", "builtin_terms", "byte_offset", "cindent", "clientserver", "clipboard", "cmdline_compl", "cmdline_hist", "cmdline_info", "comments", "compatible", "cryptv", "cscope", "debug", "dialog_con", "dialog_gui", "diff", "digraphs", "dnd", "dos16", "dos32", "ebcdic", "emacs_tags", "eval", "ex_extra", "extra_search", "farsi", "file_in_path", "filterpipe", "find_in_path", "float", "fname_case", "folding", "footer", "fork", "fullscreen", "gettext", "gui", "gui_athena", "gui_gnome", "gui_gtk", "gui_gtk2", "gui_mac", "gui_macvim", "gui_motif", "gui_photon", "gui_running", "gui_win32", "gui_win32s", "hangul_input", "iconv", "insert_expand", "jumplist", "keymap", "langmap", "libcall", "linebreak", "lispindent", "listcmds", "localmap", "lua", "mac", "macunix", "menu", "mksession", "modify_fname", "mouse", "mouse_dec", "mouse_gpm", "mouse_netterm", "mouse_pterm", "mouse_sysmouse", "mouse_xterm", "mouseshape", "multi_byte", "multi_byte_encoding", "multi_byte_ime", "multi_lang", "mzscheme", "netbeans_enabled", "netbeans_intg", "odbeditor", "ole", "os2", "path_extra", "perl", "persistent_undo", "postscript", "printer", "profile", "python", "python3", "qnx", "quickfix", "reltime", "rightleft", "ruby", "scrollbind", "showcmd", "signs", "smartindent", "sniff", "spell", "startuptime", "statusline", "sun_workshop", "syntax", "syntax_items", "system", "tag_binary", "tag_old_static", "tag_any_white", "tcl", "terminfo", "termresponse", "textobjects", "tgetent", "title", "toolbar", "transparency", "unix", "user_commands", "vertsplit", "vim_starting", "viminfo", "virtualedit", "visual", "visualextra", "vms", "vreplace", "wildignore", "wildmenu", "win16", "win32", "win32unix", "win64", "win95", "winaltkeys", "windows", "writebackup", "xfontset", "xim", "xsmp", "xsmp_interact", "xterm_clipboard", "xterm_save", "x11"]

It took like 30 second to compile it from :h feature-list.

share|improve this answer
Thanks! :) Do you think the app should expose this in the form of a dictionary? Keys = features, Values = 1/0 (maybe?). I was looking for programmatic access.. as you have with "has(feature)" – Robottinosino Feb 1 '13 at 14:05
I'm not exactly sure I understand what you want to do. I'd go with a dictionary, yes, and loop through it – romainl Feb 1 '13 at 14:26
What I wanted to do was to discover whether Vim natively exposed this information so that I could query it without having to "parse" the help page for feature-list... like I can do for individual features (e.g. has("syntax") to see if the binary was compiled with syntax capabilities) – Robottinosino Feb 1 '13 at 14:35
And the answer is still "no". Vim doesn't seem to expose that so you must come up with your own list and compare feature by feature. – romainl Feb 1 '13 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .