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