2 This is part of the VimFx documentation.
3 Copyright Simon Lydell 2015.
4 See the file README.md for copying conditions.
9 VimFx can be configured using a configuration file. This should be done by users
12 - prefer to configure things using text files.
13 - would like to add [custom commands].
14 - would like to set [special options].
15 - would like to make [site-specific customizations][overrides].
16 - would like to customize [which elements do and don’t get hints][hint-matcher].
18 Look at the [Share your config file] wiki page for inspiration.
20 You get far just by copying and pasting.
22 [custom commands]: api.md#vimfxaddcommandoptions-fn
23 [special options]: options.md#special-options
24 [overrides]: api.md#vimfxaddoptionoverridesrules-and-vimfxaddkeyoverridesrules
25 [hint-matcher]: api.md#vimfxhintmatcher
26 [Share your config file]: https://github.com/akhodakivskiy/VimFx/wiki/Share-your-config-file
31 The config file is written in JavaScript and is actually a regular Firefox
32 add-on, that makes use of VimFx’s [public API]. Don’t worry, creating such an
33 add-on is a lot easier than it might sound.
35 **[VimFx Config template – Download and instructions][config-template]**
37 Follow the above link to get started. Basically, download a few files and put
38 them in a place where Firefox can find them.
41 [config-template]: https://github.com/lydell/VimFx-config/
46 This is the actual config file, written in JavaScript. It is in this file you
47 add custom commands and set options, or whatever you’d like to do.
49 If you add custom commands, remember to [add shortcuts to
50 them][custom-command-shortcuts]!
55 vimfx.set('hint_chars', 'abcdefghijklmnopqrstuvwxyz')
56 vimfx.set('custom.mode.normal.zoom_in', 'zi')
59 [custom-command-shortcuts]: api.md#user-content-custom-command-shortcuts
64 If you add custom commands which access web page content, put their “frame
65 script code” in this file.
67 This file is also where usage of the [frame script API] goes.
69 [frame script API]: api.md#frame-script-api
71 Here’s a typical pattern used in custom commands that communicate with a frame
76 let {messageManager} = vim.window.gBrowser.selectedBrowser
77 let callback = ({data: {selection}}) => {
78 messageManager.removeMessageListener('VimFx-config:selection', callback)
79 console.log('Currently selected text:', selection)
81 messageManager.addMessageListener('VimFx-config:selection', callback)
82 messageManager.sendAsyncMessage('VimFx-config:getSelection', {exampleValue: 1337})
85 And here’s some accompanying frame script code:
89 addMessageListener('VimFx-config:getSelection', ({data: {exampleValue}}) => {
90 console.log('exampleValue should be 5:', exampleValue)
91 let selection = content.getSelection().toString()
92 sendAsyncMessage('VimFx-config:selection', {selection})