]> git.gir.st - VimFx.git/blob - documentation/options.md
Show pref name for regular options in docs
[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 settings 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’d like VimFx to pretend that some other keyboard layout than the
81 standard en-US QWERTY is always used, you may do so with the special option
82 [`translations`].)
83
84 [Hints mode]: commands.md#the-hint-commands--hints-mode
85 [`translations`]: #translations
86
87 ### Blacklist
88
89 `blacklist`
90
91 Space separated list of URL patterns where VimFx should automatically enter
92 Ignore mode. Example:
93
94 *example.com* http://example.org/editor/*
95
96 The fastest way to blacklist the page you’re currently on, is to use the `gB`
97 command. It opens a modal with a text input filled in with the blacklist, and
98 with `*currentdomain.com*` added at the start for you! Edit it if needed, or
99 just press `<enter>` straight away to save. Ignore mode is then automatically
100 entered (if the URL patterns apply).
101
102 Note that the URLs in the list must match the current URL _entirely_ for it to
103 apply. Therefore it is easiest to always use the `*` wildcard (which matches
104 zero or more characters).
105
106 Set the option to `*` to make VimFx start out in Ignore mode _everywhere._
107
108 When you’re done editing the blacklist, go to one of the pages you intend to
109 match. If you already have a tab open for that page, reload it. Then look at
110 VimFx’s [button] to see if your edits work out.
111
112 Note that when Ignore mode is automatically entered because of the blacklist, it
113 is also automatically exited (returning to Normal mode) if you go to a
114 non-blacklisted page in the same tab. On the other hand, if you entered Ignore
115 mode by pressing `i`, you’ll stay in Ignore mode in that tab until you exit it,
116 even if you navigate to another page.
117
118 You might also want to read about the [Ignore mode `<s-f1>` command][s-f1].
119
120 [button]: button.md
121 [s-f1]: commands.md#ignore-mode-s-f1
122
123 #### Blacklisting specific elements
124
125 VimFx automatically enters Ignore mode while Vim-style editors are focused, such
126 as the [wasavi] extension and [CodeMirror editors in Vim mode][codemirror-vim].
127
128 By default, VimFx lets you press `<escape>` to blur text inputs. Also by
129 default, Vim-style editors use `<escape>` to exit from their Insert mode to
130 their Normal mode. In other words, there is a keyboard shortcut conflict here.
131
132 It makes the most sense to let the Vim-style editor “win.” That’s why VimFx
133 (temporarily) enters Ignore mode when focusing such an editor. In Ignore mode,
134 there is no `<escape>` shortcut (by default), and thus no conflict. Instead,
135 there’s `<s-escape>` to blur the current element and exit Ignore mode.
136 `<s-escape>` was chosen because it is very unlikely to cause conflicts. If it
137 ever does, there’s the [`<s-f1>`] command to the rescue.
138
139 There is currently no way of specifying your own elements to be blacklisted, but
140 such a feature could be added if there’s demand for it.
141
142 [wasavi]: http://appsweets.net/wasavi/
143 [codemirror-vim]: https://codemirror.net/demo/vim.html
144 [`<s-f1>`]: commands.md#ignore-mode-s-f1
145
146 ### Hint characters
147
148 `hints.chars`
149
150 The characters used for the hints in Hints mode, which can be entered using one
151 of the many [hint commands].
152
153 Tip: Prefer filtering hints by element text? Use only uppercase hint characters,
154 or only numbers.
155
156 #### Easy-to-type and performant hints
157
158 Quick suggestion: Put more easily reachable keys longer to the left. Put two
159 pretty good (but not the best) keys at the end, after the space.
160
161 Some hint characters are easier to type than others. Many people think that the
162 ones on the home row are the best. VimFx favors keys to the left. That’s why you
163 should put better keys longer to the left.
164
165 The hint characters always contain a single space. This splits them into two
166 groups: _primary_ hint characters (before the space), and _secondary_ hint
167 characters (after the space). Read on to find out why.
168
169 Some markable elements are quicker to find than others. Therefore, VimFx looks
170 for markable elements in two passes for some commands, such as the `f` command.
171 (This is why all hints don’t always appear on screen at the same time). If two
172 passes are used, hints from the _first_ pass can only begin with _primary_ hint
173 characters. In all other cases hints may start with _any_ hint character.
174
175 When choosing how many secondary hint characters you want (there are two by
176 default), think about this: Usually most markable elements are found in the
177 first pass, while fewer are found in the second pass. So it makes sense to have
178 more primary hint characters than secondary. It’s a tradeoff. If you think the
179 hints from the first pass are too long, you probably need more primary hint
180 characters. On the other hand, if you think the hints from the _second_ pass are
181 too long, you might need a few extra secondary hint characters, but remember
182 that it might be at the expense of longer hints in the first pass.
183
184 All of this also help you understand why hints may be slow on some pages:
185
186 - One reason could be that most hints come from a second pass, which are slower
187 to compute (and are worse than first pass hints).
188
189 If a site gets an unusual amount of second pass hints, it might be because the
190 site is badly coded accessibility-wise. If so, consider contacting the site
191 and telling them so, which improves their accessibility for everyone!
192
193 - Another reason could be that a page has a _huge_ amount of links. If that
194 bothers you regularly, feel free to send a pull request with faster code!
195
196 #### Filtering hints by element text
197
198 All characters other than the hint characters are used to filter hint markers by
199 element text.
200
201 The filtering works like in Firefox’s location bar. In short, that means:
202
203 - It is case insensitive.
204 - Your typed characters are split on spaces. Each part must be present in the
205 element text (in any order, and they may overlap).
206
207 By default, “f” is a hint character. If you type an “f”, that character is used
208 to match the hints on screen. If you type an “F” (uppercase), though, which is
209 _not_ a hint character by default, you will filter the hints based on element
210 text, causing some hints markers to disappear, and the rest to be replaced. Only
211 the markable elements with text containing an “f” or “F” will now get a hint
212 marker. All the “f”s and “F”s are highlighted on the page, to help you keep
213 track of what’s going on. Keep typing other non-hint characters to further
214 reduce the number of hint markers, and make the hints shorter all the time.
215
216 Hint markers are usually displayed in uppercase, because it looks nicer.
217 However, if you mix both lowercase and uppercase hint characters, they will be
218 displayed as-is, so you can tell them apart. It is recommended to either use
219 _only_ lowercase or _only_ uppercase characters, though.
220
221 Some people prefer to filter hint markers by element text in the first hand,
222 rather than typing hint characters. If so, it is a good idea to choose all
223 uppercase hint characters, or only numbers. This way, you can press `f` and then
224 simply begin typing the text of the link you wish to follow.
225
226 [hint commands]: commands.md#the-hint-commands--hints-mode
227
228 ### Hint auto-activation
229
230 `hints.auto_activate`
231
232 The marker (or markers in the case where several links go to the same place and
233 have gotten the same hint) with the best hint are highlighted in a different
234 color. You may at any time press `<enter>` to activate those markers.
235
236 One workflow is to type non-hint characters until the hint marker of the element
237 you want to activate gets highlighted, and then hit `<enter>`. However, if _all_
238 hint markers end up highlighted (because the text you’ve typed uniquely
239 identifies a single link) the highlighted markers will be activated
240 _automatically._
241
242 If you dislike that, disable this option. Then, you either have to press
243 `<enter>` or a hint character to activate hint markers.
244
245 ### Auto-activation timeout
246
247 `hints.timeout`
248
249 If you type quickly, you might find that you will keep typing even after a hint
250 marker has been automatically activated (see [Hint auto-activation]). You might
251 simply not react that quickly. This might cause you to accidentally trigger
252 VimFx commands. Therefore, VimFx ignores all your keypresses for a certain
253 number of milliseconds when having automatically activated a hint marker after
254 filtering by element text. This option controls exactly how many milliseconds
255 that is.
256
257 If you can’t find a timeout that works for you, you might want to disable [Hint
258 auto-activation] instead.
259
260 [Hint auto-activation]: #hint-auto-activation
261
262 ### Timeout
263
264 `timeout`
265
266 The maximum amount of time (in milliseconds) that may pass between two
267 keypresses of a shortcut.
268
269 It’s easy to press, say, `a` by mistake while browsing. Without a timeout, you
270 might be surprised that all search results are highlighted when you a bit later
271 try to search using the `/` command. (That’s what `a/` does.) _With_ a timeout,
272 the `a` would be cancelled when the timeout has passed.
273
274 ### “Previous”/“Next” link patterns
275
276 `prev_patterns`/`next_patterns`
277
278 Space separated lists of patterns that match links to the previous/next page.
279 Used by the `[` and `]` commands.
280
281 There is a standardized way for websites to tell browsers the URLs to the
282 previous and next page. VimFx looks for that information in the first place.
283 Unfortunately, many websites don’t provide this information. Then VimFx falls
284 back on looking for links on the page that seem to go to the previous/next page
285 using patterns.
286
287 The patterns are matched at the beginning and end of link text (and the
288 attributes defined by the advanced setting [`pattern_attrs`]). The patterns do
289 not match in the middle of words, so “previous” does not match “previously”.
290 The matching is case <strong>in</strong>sensitive.
291
292 Actually, the patterns are regular expressions. If you do not know what a
293 regular expression is, that’s fine. You can type simple patterns like the
294 default ones without problems. If you do know what it is, though, you have the
295 possibility to create more advanced patterns if needed.
296
297 Some of the default patterns are English words. You might want to add
298 alternatives in your own language.
299
300 Note: If you need to include a space in your pattern, use `\s`. For example:
301 `next\spage`.
302
303 [`pattern_attrs`]: #pattern_attrs
304
305
306 ## Advanced options
307
308 These options are _not_ available in VimFx’s settings page in the Add-ons
309 Manager. They can only be changed in [about:config] or using a [config file].
310 They all start with `extensions.VimFx.`.
311
312 (There are actually a few more advanced options than those listed here. You can
313 see them all in [defaults.coffee].)
314
315 [about:config]: http://kb.mozillazine.org/About:config
316 [config file]: config-file.md
317 [defaults.coffee]: ../extension/lib/defaults.coffee
318
319 ### `notifications_enabled`
320
321 Controls whether [notifications] should be shown or not.
322
323 You can also choose to show notifications any way you want by listening for the
324 [the `notification` and `hideNotification` events][notification-events].
325
326 [notifications]: notifications.md
327 [notification-events]: api.md#the-notification-and-hidenotification-events
328
329 ### `notify_entered_keys`
330
331 If enabled, a [notification] is shown with the keys you have entered so far of
332 a command. This is only noticeable if you type a multi-key shortcut or use a
333 count, or if you filter hint markers by element text (then, the text you’ve
334 typed will be shown).
335
336 [notification]: notifications.md
337
338 ### `prevent_target_blank`
339
340 You might have noticed that some links open in new tabs when you click them.
341 That is not the case if you “click” them using VimFx’s `f` command, though. If
342 you dislike that, disable this option.
343
344 ### `counts_enabled`
345
346 Controls whether [counts] are enabled or not.
347
348 [counts]: commands.md#counts
349
350 ### `find_from_top_of_viewport`
351
352 Toggles whether the various find commands are Vim-style or Firefox
353 default-style.
354
355 Disable this pref if you want `/` to work more like `<c-f>` and `n`/`N` to work
356 more like `<f3>`/`<s-f3>`.
357
358 If there is selected text on the page, Firefox starts searching after that.
359 VimFx does so too, but only if the selection is currently _visible_ (inside the
360 current viewport).
361
362 If there _isn’t_ selected text on the page, Firefox starts searching from the
363 top of the page. VimFx instead starts searching from the top of the current
364 viewport.
365
366 The VimFx behavior is designed to be less disorienting. It is also similar to
367 how searching in Vim works. Again, you can return to the Firefox default
368 behavior (if you prefer that) by disabling this pref.
369
370 One of the main benefits of the VimFx behavior is that you can scroll past a
371 block of the text with lots of search matches and then continue going through
372 matches with `n` after that block, without having to spam `n` lots and lots of
373 times.
374
375 ### `ignore_ctrl_alt`
376
377 This option is enabled by default on Windows, and disabled otherwise.
378
379 If enabled, ignores ctrl+alt for printable keys. `<a-c-$>` becomes `$` and
380 `<a-c-A>` becomes `A`, while `<a-c-enter>` stays the same.
381
382 This option is suitable on Windows, which treats [AltGr as
383 ctrl+alt][wikipedia-altgr]. For example, if a user of the sv-SE layout on
384 Windows holds AltGr and presses the key labeled `4`, in order to produce a `$`,
385 the result would be `<a-c-$>` without this option, making it impossible to
386 trigger a keyboard shortcut containing `$`. _With_ this option the result is
387 `$`, as expected (and as on GNU/Linux). On the other hand it won’t be possible
388 to trigger keyboard shortcuts such as `<a-c-a>`, but ctrl+alt keyboard shortcuts
389 are [discouraged on Windows][wikipedia-altgr] anyway because of this reason.
390
391 [wikipedia-altgr]: https://en.wikipedia.org/wiki/AltGr_key#Control_.2B_Alt_as_a_substitute
392
393 ### `prevent_autofocus_modes`
394
395 Space separated list of modes where `prevent_autofocus` should be used.
396
397 ### `config_file_directory`
398
399 VimFx can optionally be customized using a [config file]. If you want to that,
400 you need to tell VimFx where that file is. That’s what this pref is for.
401
402 By default this pref is blank (the empty string), which means that no config
403 file should be loaded.
404
405 If non-blank, it should be the path to the directory where the config file
406 exists. See the [config file] documentation for more information.
407
408 [config file]: config-file.md
409
410 ### `blur_timeout`
411
412 The number of milliseconds VimFx should wait after an element has been blurred
413 before checking if you’re inside a text input or not.
414
415 Some sites with fancy text inputs (such as twitter) blur the text input for a
416 split second and then re-focus it again while typing (for some reason). If you
417 happen to press a key during that split second, that key might trigger a VimFx
418 shortcut instead of typing into the text input, which can be quite annoying. To
419 avoid the problem, VimFx waits a bit before checking if you have left the text
420 input.
421
422 ### Scrolling prefs
423
424 Apart from its own prefs, VimFx also respects a few built-in Firefox prefs.
425
426 #### Smooth scrolling
427
428 If you want to customize Firefox’s smooth scrolling, adjusting
429 `general.smoothScroll.{lines,pages,other}.duration{Min,Max}MS` is the way to
430 go. VimFx has similar prefs for the scrolling commands, but they work like
431 `layout.css.scroll-behavior.spring-constant`.
432
433 Basically, the higher the value, the faster the scrolling.
434
435 These are VimFx’s variants, and the commands they affect:
436
437 - `smoothScroll.lines.spring-constant`: `h`, `l`, `j`, `k`
438 - `smoothScroll.pages.spring-constant`: `d`, `u`, `<space>`, `<s-space>`
439 - `smoothScroll.other.spring-constant`: `gg`, `G`, `0`, `^`, `$`, `'`
440
441 Note that the value of these prefs are _strings,_ not numbers!
442
443 Unfortunately, Firefox provides no way for code to tell which “spring constant”
444 it wants when scrolling smoothly. All VimFx can do is to temporarily set
445 Firefox’s `layout.css.scroll-behavior.spring-constant` pref. It is reset again
446 after one second (by default). If that doesn’t work out for you, you can
447 customize that timeout using the `scroll.reset_timeout` pref.
448
449 The Firefox pref `general.smoothScroll` lets you turn off smooth scrolling
450 entirely, including all of VimFx’s scrolling commands.
451
452 `general.smoothScroll.lines`, `general.smoothScroll.pages`, and
453 `general.smoothScroll.other` lets you selectively disable smooth scrolling.
454 VimFx’s scrolling commands follow the same “lines,” “pages” and “other”
455 categorization as in the above list.
456
457 #### Scroll step
458
459 By default you can scroll using the arrow keys in Firefox. You can control how
460 much they scroll by adjusting the following prefs:
461
462 - `toolkit.scrollbox.horizontalScrollDistance`: `<left>`, `<right>`, `h`, `l`
463 - `toolkit.scrollbox.verticalScrollDistance`: `<down>`, `<up>`, `j`, `k`
464
465 (VimFx used to have a `scroll_step` pref, but is has been replaced by the
466 above.)
467
468 #### `scroll.full_page_adjustment` and `scroll.half_page_adjustment`
469
470 An important use case for scrolling a full page down is to read an entire page
471 (a window-full) of text, press `<space>` and then continue reading the next
472 page. However, if you can only see, say, _half_ of the height the last line,
473 pressing `<space>` would give you the other half, but reading only the top or
474 bottom parts of letters is difficult. Even if the lines happen to line up with
475 the window edge to not be sliced horizontally, it might feel disorienting
476 pressing `<space>`.
477
478 For this reason, both VimFx and Firefox by default scroll _about a line less
479 than a whole page_ when pressing `<space>`. This solves the sliced-last-line
480 problem, and provides some context on where you are in the text you’re reading.
481
482 These two prefs control how many pixels “about a line” actually means for the
483 different page scrolling commands.
484
485 - `scroll.full_page_adjustment`: `<space>, `<s-space>`
486 - `scroll.half_page_adjustment`: `d`, `u`
487
488 #### `scroll.last_position_mark`
489
490 The special mark for the [`'`][scroll-to-mark] command that takes you to the
491 last position.
492
493 [scroll-to-mark]: commands.md#marks-m-and-
494
495 ### `pattern_selector`
496
497 A CSS selector that targets candidates for a previous/next page link.
498
499 ### `pattern_attrs`
500
501 A space-separated list of attributes that the [“Previous”/“Next” link patterns]
502 should be matched against.
503
504 [“Previous”/“Next” link patterns]: #previousnext-link-patterns
505
506 ### `hints.matched_timeout`
507
508 The number of milliseconds a matched hint marker should stay on screen before
509 disappearing (or resetting).
510
511 ### `hints.sleep`
512
513 In Hints mode, VimFx continually checks if the element for a hint marker has
514 moved. If so, the marker is moved as well. This pref controls how many
515 milliseconds VimFx should “sleep” between each check. The shorter, the more CPU
516 usage, the longer, the more stuttery marker movement.
517
518 The default value should work fine, but if you have a low-performing computer
519 and you notice bothering CPU usage during Hints mode you might want to raise the
520 sleep time.
521
522 Set it to -1 to disable the marker movement feature entirely.
523
524 ### `hints.match_text`
525
526 If you strongly dislike that typing non-[Hint characters] filters hint markers
527 by element text, disable this pref. (That’ll make things work like it did in
528 VimFx 0.18.x and older.)
529
530 [Hint characters]: #hint-characters
531
532 ### `hints.peek_through`
533
534 This pref doesn’t do much. If you’ve used custom [styling] to change which
535 modifier lets you peek through markers in [Hints mode], you might want to change
536 this pref as well. Otherwise VimFx’s Keyboard Shortcuts dialog will still tell
537 you to press shift for this task.
538
539 [styling]: styling.md
540 [Hints mode]: commands.md#the-hint-commands--hints-mode
541
542 ### `hints.toggle_in_tab`
543
544 If the keypress that matched a hint starts with this string, toggle whether to
545 open the matched link in the current tab or a new tab. See the [hint commands]
546 for more information.
547
548 ### `hints.toggle_in_background`
549
550 If the keypress that matched a hint starts with this string, open the matched
551 link in a new tab and toggle whether to open that tab in the background or
552 foreground. See the [hint commands] for more information.
553
554 ### `activatable_element_keys`
555
556 Keys that should not trigger VimFx commands but be sent through to the page if
557 an “activatable” element (link or button) is focused.
558
559 ### `adjustable_element_keys`
560
561 Keys that should not trigger VimFx commands but be sent through to the page if
562 an “adjustable” element (form control or video player) is focused.
563
564 ### `focus_previous_key` and `focus_next_key`
565
566 The default values are `<s-tab` and `<tab>`, respectively. Those keys are
567 specially handled after focusing a text input using [`gi`]. To disable this
568 special handling, set the prefs to the empty string.
569
570 [`gi`]: commands.md#gi-1
571
572
573 ## Special options
574
575 These options are available in neither VimFx’s settings page in the Add-ons
576 Manager nor in [about:config]. The only way to change them is by using the
577 a [config file].
578
579 ### `translations`
580
581 See the description of the `translations` option in [vim-like-key-notation].
582
583 [vim-like-key-notation]: https://github.com/lydell/vim-like-key-notation#api
584
585 ### `categories`
586
587 See the documentation for [`vimfx.get('categories')`][categories].
588
589 [categories]: api.md#vimfxgetcategories
Imprint / Impressum