]> git.gir.st - VimFx.git/blob - documentation/options.md
Make Caret browsing handling more robust
[VimFx.git] / documentation / options.md
1 <!--
2 This is part of the VimFx documentation.
3 Copyright Simon Lydell 2015, 2016.
4 See the file README.md for copying conditions.
5 -->
6
7 # Options
8
9 VimFx has many options that can be configured, but they all have nice defaults
10 so you shouldn’t need to.
11
12 Advanced users might also be interested in [styling] VimFx and writing a [config
13 file].
14
15 [styling]: styling.md
16 [config file]: config-file.md
17
18
19 ## Regular options
20
21 These options are available in VimFx’s options page in the Add-ons Manager
22 (where you can also customize [keyboard shortcuts]).
23
24 [keyboard shortcuts]: shortcuts.md
25
26 ### Prevent autofocus
27
28 `prevent_autofocus`
29
30 Many sites autofocus their search box, for example. This might be annoying when
31 browsing using the keyboard, as you do with VimFx, because it often feels like
32 VimFx isn’t responding, until you realize that you are typing in a text box—not
33 running VimFx commands!
34
35 For this reason VimFx can prevent autofocus. It’s not enabled by default,
36 though, since one of VimFx’s key features is to be nice to your browser and your
37 habits.
38
39 If enabled, all focusing that occurs on page load, or after you’ve just switched
40 back to a tab from another, until you interact with the page is prevented.
41
42 #### Technical notes and trivia
43
44 Autofocus on page load and when coming back to a tab are the two most common
45 cases. Some sites, though, automatically focus a text input in other cases as
46 well. Trying to catch those cases as well, VimFx used to prevent all focusing
47 that didn’t occur within a fixed number of milliseconds after your last
48 interaction (click or keypress). However, this proved to be too aggressive,
49 preventing too much focusing. In other words, the time-based check was not
50 sufficient to distinguish between intended focusing and automatic unwanted
51 focusing. It made things worse more than it helped. Since these cases are so
52 difficult (if not impossible) to detect, it is better to leave them. Thankfully
53 they are not very common.
54
55 On page load or when coming back to a tab, before you have interacted with the
56 page in any way, we can be _sure_ that any focusing is automatic (not caused by
57 you), which makes it safe to prevent all focusing in those time spans.
58
59 ### Ignore keyboard layout
60
61 `ignore_keyboard_layout`
62
63 If you use more than one keyboard layout, you probably want to enable this
64 option.
65
66 People who use a keyboard layout _without_ the letters A–Z usually also use the
67 standard en-US QWERTY layout as well.
68
69 This option makes VimFx ignore your current layout and pretend that the standard
70 en-US QWERTY layout is _always_ used. This way the default shortcuts work even
71 if your layout doesn’t contain the letters A–Z and all shortcuts can be typed by
72 the same physical keys on your keyboard regardless of your current keyboard
73 layout.
74
75 Note that when filtering hints markers by element text (but not when typing hint
76 characters) in [Hints mode], your current layout _is_ used, even if you’ve
77 enabled ignoring of it. That’s because otherwise you wouldn’t be able to filter
78 by element text in any other language than English.
79
80 If you have modified your keyboard layout slightly using software, such as
81 having swapped `<capslock>` and `<escape>`, this option will cause VimFx to
82 ignore that as well. If that’s unwanted, you need to tell VimFx about your
83 layout customizations by using the special option [`translations`].
84
85 If you’d like VimFx to pretend that some other keyboard layout than the standard
86 en-US QWERTY is always used, that’s also a job for the special option
87 [`translations`].
88
89 [Hints mode]: commands.md#the-hint-commands--hints-mode
90 [`translations`]: #translations
91
92 ### Blacklist
93
94 `blacklist`
95
96 Space separated list of URL patterns where VimFx should automatically enter
97 Ignore mode. Example:
98
99 *example.com* http://example.org/editor/*
100
101 **The fastest way** to blacklist the page you’re currently on, is to **use the
102 `gB` command.** It opens a modal with a text input filled in with the blacklist,
103 and with `*currentdomain.com*` added at the start for you! Edit it if needed, or
104 just press `<enter>` straight away to save. Ignore mode is then automatically
105 entered (if the URL patterns apply).
106
107 Note that the URLs in the list must match the current URL _entirely_ for it to
108 apply. Therefore it is easiest to always use the `*` wildcard (which matches
109 zero or more characters).
110
111 Set the option to `*` to make VimFx start out in Ignore mode _everywhere._
112
113 When you’re done editing the blacklist, go to one of the pages you intend to
114 match. If you already have a tab open for that page, reload it. Then look at
115 VimFx’s [button] to see if your edits work out.
116
117 Note that when Ignore mode is automatically entered because of the blacklist, it
118 is also automatically exited (returning to Normal mode) if you go to a
119 non-blacklisted page in the same tab. On the other hand, if you entered Ignore
120 mode by pressing `i`, you’ll stay in Ignore mode in that tab until you exit it,
121 even if you navigate to another page.
122
123 You might also want to read about the [Ignore mode `<s-f1>` command][s-f1].
124
125 [button]: button.md
126 [s-f1]: commands.md#ignore-mode-s-f1
127
128 #### Blacklisting specific elements
129
130 VimFx automatically enters Ignore mode while Vim-style editors are focused, such
131 as the [wasavi] extension and [CodeMirror editors in Vim mode][codemirror-vim].
132
133 By default, VimFx lets you press `<escape>` to blur text inputs. Also by
134 default, Vim-style editors use `<escape>` to exit from their Insert mode to
135 their Normal mode. In other words, there is a keyboard shortcut conflict here.
136
137 It makes the most sense to let the Vim-style editor “win.” That’s why VimFx
138 (temporarily) enters Ignore mode when focusing such an editor. In Ignore mode,
139 there is no `<escape>` shortcut (by default), and thus no conflict. Instead,
140 there’s `<s-escape>` to blur the current element and exit Ignore mode.
141 `<s-escape>` was chosen because it is very unlikely to cause conflicts. If it
142 ever does, there’s the [`<s-f1>`] command to the rescue.
143
144 There is currently no way of specifying your own elements to be blacklisted, but
145 such a feature could be added if there’s demand for it.
146
147 [wasavi]: http://appsweets.net/wasavi/
148 [codemirror-vim]: https://codemirror.net/demo/vim.html
149 [`<s-f1>`]: commands.md#ignore-mode-s-f1
150
151 ### Hint characters
152
153 `hints.chars`
154
155 The characters used for the hints in Hints mode, which can be entered using one
156 of the many [hint commands].
157
158 **Tip:** Prefer filtering hints by element text? Use only uppercase hint
159 characters (such as `FJDKSLAGHRUEIWONC MV`), or only numbers (`01234567 89`).
160
161 [hint commands]: commands.md#the-hint-commands--hints-mode
162
163 #### Filtering hints by element text
164
165 All characters other than the hint characters are used to filter hint markers by
166 element text.
167
168 The filtering works like in Firefox’s location bar. In short, that means:
169
170 - It is case insensitive.
171 - Your typed characters are split on spaces. Each part must be present in the
172 element text (in any order, and they may overlap).
173
174 By default, “f” is a hint character. If you type an “f”, that character is used
175 to match the hints on screen. If you type an “F” (uppercase), though, which is
176 _not_ a hint character by default, you will filter the hints based on element
177 text, causing some hints markers to disappear, and the rest to be replaced. Only
178 the markable elements with text containing an “f” or “F” will now get a hint
179 marker. All the “f”s and “F”s are highlighted on the page, to help you keep
180 track of what’s going on. Keep typing other non-hint characters to further
181 reduce the number of hint markers, and make the hints shorter all the time.
182
183 Hint markers are usually displayed in uppercase, because it looks nicer.
184 However, if you mix both lowercase and uppercase hint characters, they will be
185 displayed as-is, so you can tell them apart. It is recommended to either use
186 _only_ lowercase or _only_ uppercase characters, though.
187
188 Some people prefer to filter hint markers by element text in the first hand,
189 rather than typing hint characters. If so, it is a good idea to choose all
190 uppercase hint characters, or only numbers. This way, you can press `f` and then
191 simply begin typing the text of the link you wish to follow.
192
193 #### Easy-to-type and performant hints
194
195 Quick suggestion: Put more easily reachable keys longer to the left. Put two
196 pretty good (but not the best) keys at the end, after the space.
197
198 Some hint characters are easier to type than others. Many people think that the
199 ones on the home row are the best. VimFx favors keys to the left. That’s why you
200 should put better keys longer to the left.
201
202 The hint characters always contain a single space. This splits them into two
203 groups: _primary_ hint characters (before the space), and _secondary_ hint
204 characters (after the space). Read on to find out why.
205
206 Some markable elements are quicker to find than others. Therefore, VimFx looks
207 for markable elements in two passes for some commands, such as the `f` command.
208 (This is why all hints don’t always appear on screen at the same time). If two
209 passes are used, hints from the _first_ pass can only begin with _primary_ hint
210 characters. In all other cases hints may start with _any_ hint character.
211
212 When choosing how many secondary hint characters you want (there are two by
213 default), think about this: Usually most markable elements are found in the
214 first pass, while fewer are found in the second pass. So it makes sense to have
215 more primary hint characters than secondary. It’s a tradeoff. If you think the
216 hints from the first pass are too long, you probably need more primary hint
217 characters. On the other hand, if you think the hints from the _second_ pass are
218 too long, you might need a few extra secondary hint characters, but remember
219 that it might be at the expense of longer hints in the first pass.
220
221 All of this also help you understand why hints may be slow on some pages:
222
223 - One reason could be that most hints come from a second pass, which are slower
224 to compute (and are worse than first pass hints).
225
226 If a site gets an unusual amount of second pass hints, it might be because the
227 site is badly coded accessibility-wise. If so, consider contacting the site
228 and telling them so, which improves their accessibility for everyone!
229
230 - Another reason could be that a page has a _huge_ amount of links. If that
231 bothers you regularly, feel free to send a pull request with faster code!
232
233 ### Hint auto-activation
234
235 `hints.auto_activate`
236
237 The marker (or marker<strong>s</strong> in the case where several links go to
238 the same place and have gotten the same hint) with the best hint are highlighted
239 with a different color. You may at any time press `<enter>` to activate those
240 markers.
241
242 One workflow is to type non-hint characters until the hint marker of the element
243 you want to activate gets highlighted, and then hit `<enter>`. To make this more
244 obvious, the entire element text is selected, too. However, if _all_ hint
245 markers end up highlighted (because the text you’ve typed uniquely identifies a
246 single link) the highlighted markers will be activated _automatically._
247
248 If you dislike that, disable this option. Then, you either have to press
249 `<enter>` or a hint character to activate hint markers.
250
251 ### Auto-activation timeout
252
253 `hints.timeout`
254
255 If you type quickly, you might find that you will keep typing even after a hint
256 marker has been automatically activated (see [Hint auto-activation]). You might
257 simply not react that quickly. This might cause you to accidentally trigger
258 VimFx commands. Therefore, VimFx ignores all your keypresses for a certain
259 number of milliseconds when having automatically activated a hint marker after
260 filtering by element text. This option controls exactly how many milliseconds
261 that is.
262
263 If you can’t find a timeout that works for you, you might want to disable [Hint
264 auto-activation] instead.
265
266 [Hint auto-activation]: #hint-auto-activation
267
268 ### Timeout
269
270 `timeout`
271
272 The maximum amount of time (in milliseconds) that may pass between two
273 keypresses of a shortcut.
274
275 It’s easy to press, say, `a` by mistake while browsing. Without a timeout, you
276 might be surprised that all search results are highlighted when you a bit later
277 try to search using the `/` command. (That’s what `a/` does.) _With_ a timeout,
278 the `a` would be cancelled when the timeout has passed.
279
280 ### “Previous”/“Next” link patterns
281
282 `prev_patterns`/`next_patterns`
283
284 Space separated lists of patterns that match links to the previous/next page.
285 Used by the `[` and `]` commands.
286
287 There is a standardized way for websites to tell browsers the URLs to the
288 previous and next page. VimFx looks for that information in the first place.
289 Unfortunately, many websites don’t provide this information. Then VimFx falls
290 back on looking for links on the page that seem to go to the previous/next page
291 using patterns.
292
293 The patterns are matched at the beginning and end of link text (and the
294 attributes defined by the advanced option [`pattern_attrs`]). The patterns do
295 not match in the middle of words, so “previous” does not match “previously”.
296 The matching is case <strong>in</strong>sensitive.
297
298 Actually, the patterns are regular expressions. If you do not know what a
299 regular expression is, that’s fine. You can type simple patterns like the
300 default ones without problems. If you do know what it is, though, you have the
301 possibility to create more advanced patterns if needed.
302
303 Some of the default patterns are English words. You might want to add
304 alternatives in your own language.
305
306 Note: If you need to include a space in your pattern, use `\s`. For example:
307 `next\spage`.
308
309 [`pattern_attrs`]: #pattern_attrs
310
311
312 ## Advanced options
313
314 These options are _not_ available in VimFx’s options page in the Add-ons
315 Manager. They can only be changed in [about:config] or using a [config file].
316 They all start with `extensions.VimFx.`.
317
318 (There are actually a few more advanced options than those listed here. You can
319 see them all in [defaults.coffee].)
320
321 [about:config]: http://kb.mozillazine.org/About:config
322 [config file]: config-file.md
323 [defaults.coffee]: ../extension/lib/defaults.coffee
324
325 ### `notifications_enabled`
326
327 Controls whether [notifications] should be shown or not.
328
329 You can also choose to show notifications any way you want by listening for the
330 [the `notification` and `hideNotification` events][notification-events].
331
332 [notifications]: notifications.md
333 [notification-events]: api.md#the-notification-and-hidenotification-events
334
335 ### `notify_entered_keys`
336
337 If enabled, a [notification] is shown with the keys you have entered so far of
338 a command. This is only noticeable if you type a multi-key shortcut or use a
339 count, or if you filter hint markers by element text (then, the text you’ve
340 typed will be shown).
341
342 [notification]: notifications.md
343
344 ### `prevent_target_blank`
345
346 You might have noticed that some links open in new tabs when you click them.
347 That is not the case if you “click” them using VimFx’s `f` command, though. If
348 you dislike that, disable this option.
349
350 ### `counts_enabled`
351
352 Controls whether [counts] are enabled or not.
353
354 [counts]: commands.md#counts
355
356 ### `find_from_top_of_viewport`
357
358 Toggles whether the various find commands are Vim-style or Firefox
359 default-style.
360
361 Disable this option if you want `/` to work more like `<c-f>` and `n`/`N` to
362 work more like `<f3>`/`<s-f3>`.
363
364 If there is selected text on the page, Firefox starts searching after that.
365 VimFx does so too, but only if the selection is currently _visible_ (inside the
366 current viewport).
367
368 If there _isn’t_ selected text on the page, Firefox starts searching from the
369 top of the page. VimFx instead starts searching from the top of the current
370 viewport.
371
372 The VimFx behavior is designed to be less disorienting. It is also similar to
373 how searching in Vim works. Again, you can return to the Firefox default
374 behavior (if you prefer that) by disabling this option.
375
376 One of the main benefits of the VimFx behavior is that you can scroll past a
377 block of the text with lots of search matches and then continue going through
378 matches with `n` after that block, without having to spam `n` lots and lots of
379 times.
380
381 ### `browsewithcaret`
382
383 [Caret mode] uses [Firefox’s own Caret mode] under the hood. This means that
384 VimFx temporarily enables the Firefox option `accessibility.browsewithcaret`
385 when you are in VimFx’s Caret mode. When you leave Caret mode, that option is
386 turned off again.
387
388 VimFx automatically syncs the `browsewithcaret` option with
389 `accessibility.browsewithcaret`. If you change the latter manually (such as by
390 using the Firefox default shortcut `<f7>`), VimFx’s option is changed as well,
391 so you shouldn’t really have to touch this option at all.
392
393 [Caret mode]: commands.md#caret-mode
394 [Firefox’s own Caret mode]: http://kb.mozillazine.org/Accessibility_features_of_Firefox#Allow_text_to_be_selected_with_the_keyboard
395
396 ### `ignore_ctrl_alt`
397
398 This option is enabled by default on Windows, and disabled otherwise.
399
400 If enabled, ignores ctrl+alt for printable keys. `<a-c-$>` becomes `$` and
401 `<a-c-A>` becomes `A`, while `<a-c-enter>` stays the same.
402
403 This option is suitable on Windows, which treats [AltGr as
404 ctrl+alt][wikipedia-altgr]. For example, if a user of the sv-SE layout on
405 Windows holds AltGr and presses the key labeled `4`, in order to produce a `$`,
406 the result would be `<a-c-$>` without this option, making it impossible to
407 trigger a keyboard shortcut containing `$`. _With_ this option the result is
408 `$`, as expected (and as on GNU/Linux). On the other hand it won’t be possible
409 to trigger keyboard shortcuts such as `<a-c-a>`, but ctrl+alt keyboard shortcuts
410 are [discouraged on Windows][wikipedia-altgr] anyway because of this reason.
411
412 [wikipedia-altgr]: https://en.wikipedia.org/wiki/AltGr_key#Control_.2B_Alt_as_a_substitute
413
414 ### `prevent_autofocus_modes`
415
416 Space separated list of modes where `prevent_autofocus` should be used.
417
418 ### `config_file_directory`
419
420 VimFx can optionally be customized using a [config file]. If you want to that,
421 you need to tell VimFx where that file is. That’s what this option is for.
422
423 By default this option is blank (the empty string), which means that no config
424 file should be loaded.
425
426 If non-blank, it should be the path to the directory where the config file
427 exists. See the [config file] documentation for more information.
428
429 [config file]: config-file.md
430
431 ### `blur_timeout`
432
433 The number of milliseconds VimFx should wait after an element has been blurred
434 before checking if you’re inside a text input or not.
435
436 Some sites with fancy text inputs (such as twitter) blur the text input for a
437 split second and then re-focus it again while typing (for some reason). If you
438 happen to press a key during that split second, that key might trigger a VimFx
439 shortcut instead of typing into the text input, which can be quite annoying. To
440 avoid the problem, VimFx waits a bit before checking if you have left the text
441 input.
442
443 ### `refocus_timeout`
444
445 If you switch to another window while a text input is focused, Firefox actually
446 blurs the text input. If you then switch back again, Firefox will re-focus the
447 text input.
448
449 VimFx tracks that case, so that the [Prevent autofocus] option does not think it
450 should prevent that refocus. Unfortunately, the tracking requires a timeout.
451 This option let’s you customize that timeout (measured in milliseconds).
452
453 If you experience that text input focus is lost after switching back to Firefox
454 from another window, you might want to increase this timeout.
455
456 [Prevent autofocus]: #prevent-autofocus
457
458 ### Scrolling options
459
460 Apart from its own options, VimFx also respects a few built-in Firefox options.
461
462 #### Smooth scrolling
463
464 If you want to customize Firefox’s smooth scrolling, adjusting
465 `general.smoothScroll.{lines,pages,other}.duration{Min,Max}MS` is the way to
466 go. VimFx has similar options for the scrolling commands, but they work like
467 `layout.css.scroll-behavior.spring-constant`.
468
469 Basically, the higher the value, the faster the scrolling.
470
471 These are VimFx’s variants, and the commands they affect:
472
473 - `smoothScroll.lines.spring-constant`: `h`, `l`, `j`, `k`
474 - `smoothScroll.pages.spring-constant`: `d`, `u`, `<space>`, `<s-space>`
475 - `smoothScroll.other.spring-constant`: `gg`, `G`, `0`, `^`, `$`, `'`
476
477 Note that the value of these options are _strings,_ not numbers!
478
479 Unfortunately, Firefox provides no way for code to tell which “spring constant”
480 it wants when scrolling smoothly. All VimFx can do is to temporarily set
481 Firefox’s `layout.css.scroll-behavior.spring-constant` option. It is reset again
482 after one second (by default). If that doesn’t work out for you, you can
483 customize that timeout using the `scroll.reset_timeout` option.
484
485 The Firefox option `general.smoothScroll` lets you turn off smooth scrolling
486 entirely, including all of VimFx’s scrolling commands.
487
488 `general.smoothScroll.lines`, `general.smoothScroll.pages`, and
489 `general.smoothScroll.other` lets you selectively disable smooth scrolling.
490 VimFx’s scrolling commands follow the same “lines,” “pages” and “other”
491 categorization as in the above list.
492
493 #### Scroll step
494
495 By default you can scroll using the arrow keys in Firefox. You can control how
496 much they scroll by adjusting the following options:
497
498 - `toolkit.scrollbox.horizontalScrollDistance`: `<left>`, `<right>`, `h`, `l`
499 - `toolkit.scrollbox.verticalScrollDistance`: `<down>`, `<up>`, `j`, `k`
500
501 (VimFx used to have a `scroll_step` option, but is has been replaced by the
502 above.)
503
504 #### `scroll.horizontal_boost` and `scroll.vertical_boost`
505
506 When holding down `h`, `l`, `j` or `k` (rather than just tapping those keys),
507 their scrolling speed is sped up, just like when you hold down an arrow key to
508 scroll. These options control _how much_ the mentioned commands are sped up. The
509 usual scroll distances are multiplied by these numbers.
510
511 #### `scroll.full_page_adjustment` and `scroll.half_page_adjustment`
512
513 An important use case for scrolling a full page down is to read an entire page
514 (a window-full) of text, press `<space>` and then continue reading the next
515 page. However, if you can only see, say, _half_ of the height the last line,
516 pressing `<space>` would give you the other half, but reading only the top or
517 bottom parts of letters is difficult. Even if the lines happen to line up with
518 the window edge to not be sliced horizontally, it might feel disorienting
519 pressing `<space>`.
520
521 For this reason, both VimFx and Firefox by default scroll _about a line less
522 than a whole page_ when pressing `<space>`. This solves the sliced-last-line
523 problem, and provides some context on where you are in the text you’re reading.
524
525 These two options control how many pixels “about a line” actually means for the
526 different page scrolling commands.
527
528 - `scroll.full_page_adjustment`: `<space>, `<s-space>`
529 - `scroll.half_page_adjustment`: `d`, `u`
530
531 #### `scroll.last_position_mark` and `scroll.last_find_mark`
532
533 These options allow you to customize the [special marks] for the
534 [`'`][scroll-to-mark] command.
535
536 [special marks]: commands.md#special-marks
537 [scroll-to-mark]: commands.md#marks-m-and-
538
539 ### `pattern_selector`
540
541 A CSS selector that targets candidates for a previous/next page link.
542
543 ### `pattern_attrs`
544
545 A space-separated list of attributes that the [“Previous”/“Next” link patterns]
546 should be matched against.
547
548 [“Previous”/“Next” link patterns]: #previousnext-link-patterns
549
550 ### `hints.matched_timeout`
551
552 The number of milliseconds a matched hint marker should stay on screen before
553 disappearing (or resetting).
554
555 ### `hints.sleep`
556
557 In Hints mode, VimFx continually checks if the element for a hint marker has
558 moved. If so, the marker is moved as well. This option controls how many
559 milliseconds VimFx should “sleep” between each check. The shorter, the more CPU
560 usage, the longer, the more stuttery marker movement.
561
562 The default value should work fine, but if you have a low-performing computer
563 and you notice bothering CPU usage during Hints mode you might want to raise the
564 sleep time.
565
566 Set it to -1 to disable the marker movement feature entirely.
567
568 ### `hints.match_text`
569
570 If you strongly dislike that typing non-[Hint characters] filters hint markers
571 by element text, disable this option. (That’ll make things work like it did in
572 VimFx 0.18.x and older.)
573
574 [Hint characters]: #hint-characters
575
576 ### `hints.peek_through`
577
578 This option doesn’t do much. If you’ve used custom [styling] to change which
579 modifier lets you peek through markers in [Hints mode], you might want to change
580 this option as well. Otherwise VimFx’s Keyboard Shortcuts dialog will still tell
581 you to press shift for this task.
582
583 [styling]: styling.md
584 [Hints mode]: commands.md#the-hint-commands--hints-mode
585
586 ### `hints.toggle_in_tab`
587
588 If the keypress that matched a hint starts with this string, toggle whether to
589 open the matched link in the current tab or a new tab. See the [hint commands]
590 for more information.
591
592 ### `hints.toggle_in_background`
593
594 If the keypress that matched a hint starts with this string, open the matched
595 link in a new tab and toggle whether to open that tab in the background or
596 foreground. See the [hint commands] for more information.
597
598 ### `activatable_element_keys`
599
600 Keys that should not trigger VimFx commands but be sent through to the page if
601 an “activatable” element (link or button) is focused.
602
603 ### `adjustable_element_keys`
604
605 Keys that should not trigger VimFx commands but be sent through to the page if
606 an “adjustable” element (form control or video player) is focused.
607
608 ### `focus_previous_key` and `focus_next_key`
609
610 The default values are `<s-tab` and `<tab>`, respectively. Those keys are
611 specially handled after focusing a text input using [`gi`]. To disable this
612 special handling, set the options to the empty string.
613
614 [`gi`]: commands.md#gi-1
615
616
617 ## Special options
618
619 These options are available in neither VimFx’s options page in the Add-ons
620 Manager nor in [about:config]. The only way to change them is by using the
621 a [config file].
622
623 ### `translations`
624
625 This option is only useful if you use the [Ignore keyboard layout] option. As
626 mentioned in the documentation for that option, `translations` exist to let you:
627
628 - Teach VimFx about layout customizations you’ve made, that otherwise get
629 ignored.
630 - Make VimFx pretend that some other keyboard layout than the standard en-US
631 QWERTY is always used.
632
633 Here’s some example usage:
634
635 ```js
636 vimfx.set('translations', {
637 // Swapped <capslock> and <escape>.
638 'CapsLock': 'Escape',
639 'Escape': 'CapsLock',
640
641 // AZERTY mappings.
642 'KeyQ': ['a', 'A'],
643 'KeyA': ['q', 'Q'],
644 // etc.
645
646 // Bonus: Distinguish between regular numbers and numpad numbers by
647 // translating the numpad numbers into made-up names (regardless of numlock
648 // state). Then, you can use `<k0>` to `<k9>` in shortcuts.
649 'Numpad0': 'K0',
650 'Numpad1': 'K1',
651 'Numpad2': 'K2',
652 'Numpad3': 'K3',
653 'Numpad4': 'K4',
654 'Numpad5': 'K5',
655 'Numpad6': 'K6',
656 'Numpad7': 'K7',
657 'Numpad8': 'K8',
658 'Numpad9': 'K9',
659 })
660 ```
661
662 More formally, `translations` is an object where:
663
664 - The object keys are [`event.code`] strings that should be translated.
665
666 - The object values are either strings or arrays of two strings.
667
668 If an array is provided, the first value of it is used when shift is _not_
669 held, and the other value when shift _is_ held.
670
671 If only one string is provided, that value is always used (regardless of the
672 shift state).
673
674 The strings are what you want VimFx to treat the pressed key as. For example,
675 providing `Escape` will cause the translated key to match VimFx shortcuts
676 containing `<Escape>` (or `<escape>`—the case doesn’t matter).
677
678 At this point, you might be wondering why these options to ignore your keyboard
679 layout and translate keys have to exist. It’s all about the data that is
680 available in Firefox (basically [`event.key`] and [`event.code`]). There is a
681 longer technical explanation in [vim-like-key-notation], the library VimFx uses
682 for dealing with keyboard stuff.
683
684 [Ignore keyboard layout]: #ignore-keyboard-layout
685 [`event.code`]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
686 [`event.key`]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
687 [vim-like-key-notation]: https://github.com/lydell/vim-like-key-notation#technical-notes
688
689 ### `categories`
690
691 See the documentation for [`vimfx.get('categories')`][categories].
692
693 [categories]: api.md#vimfxgetcategories
Imprint / Impressum