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.
52 vimfx.set('hint_chars', 'abcdefghijklmnopqrstuvwxyz')
58 If you add custom commands that accesses web page content, put their "frame
59 script code" in this file.
61 This file is also where usage of the [frame script API] goes.
63 [frame script API]: api.md#frame-script-api
65 Here’s a typical pattern used in custom commands that communicate with a frame
70 let {messageManager} = vim.window.gBrowser.selectedBrowser
71 let callback = ({data: {selection}}) => {
72 messageManager.removeMessageListener('VimFx-custom:selection', callback)
73 console.log('Currently selected text:', selection)
75 messageManager.addMessageListener('VimFx-custom:selection', callback)
76 messageManager.sendAsyncMessage('VimFx-custom:getSelection', {exampleValue: 1337})
79 And here’s some accompaning frame script code:
83 addMessageListener('VimFx-custom:getSelection', ({data: {exampleValue}}) => {
84 console.log('exampleValue should be 5:', exampleValue)
85 let selection = content.getSelection().toString()
86 sendAsyncMessage('VimFx-custom:selection', {selection})