Configuration of Chawan
Chawan supports configuration of various options like keybindings, user stylesheets, site preferences, etc. The configuration format is similar to toml, with the following exceptions:
- Inline tables may span across multiple lines.
- Regular tables (
[table]
) and inline tables (table = {}
) have different semantics. The first is additive, meaning old values are not removed. The second is destructive, and clears all definitions in the table specified. [[table-array]]
is sugar for[table-array.n]
, wheren
is the number of declared table arrays. For example, you can declare anonymous siteconfs using the syntax[[siteconf]]
.
The canonical configuration file path is ~/.chawan/config.toml, but the search path accommodates XDG basedirs as well:
- config file specified through -C switch -> use that
$CHA_DIR
is set -> use$CHA_DIR
/config.toml$XDG_CONFIG_HOME
is set -> use$XDG_CONFIG_HOME
/chawan/config.toml- ~/.config/chawan/config.toml exists -> use that
- ~/.chawan/config.toml exists -> use that
Table of contents
- Start
- Search
- Buffer
- Encoding
- External
- Network
- Display
- Protocol
- Omnirule
- Siteconf
- Stylesheets
- Keybindings
- Appendix
Start
Start-up options are to be placed in the [start]
section.
Following is a list of start-up options:
Name | Value | Default | Function |
---|---|---|---|
visual-home | url | “about:chawan” | Page opened when Chawan is called with the -V option and no other pages are passed as arguments. |
startup-script | JavaScript code | ““ | Script Chawan runs on start-up. Pages will not be loaded until this function exits. (Note however that asynchronous functions like setTimeout do not block loading.) |
headless | boolean / “dump” | false |
When set to true or “dump”, the browser does not take input; instead, it
prints a rendered version of all buffers in order, then exits. The difference between true and “dump” is that
true first waits for all scripts and network requests to
run to completion, while “dump” does not. This means that
true may never exit when scripting is enabled (e.g. if a
script sets setInterval .)Piping cha to an
external program or passing the -d switch has the same
effect as setting this option to “dump”.
|
console-buffer | boolean | true |
Whether Chawan should open a console buffer in non-headless mode. Warning: this is only useful for debugging. Disabling this option without manually redirecting standard error will result in error messages randomly appearing on your screen. |
Buffer
Buffer options are to be placed in the [buffer]
section.
These options are global to all buffers. For more granular filtering,
use [[siteconf]]
.
Example:
[buffer]
# show images on all websites
images = true
# disable website CSS
styling = false
# You *can* set scripting to true here, but I strongly recommend using
# [[siteconf]] to enable it on a per-site basis instead.
Following is a list of buffer options:
Name | Value | Default | Function |
---|---|---|---|
styling | boolean | true |
Enable/disable author style sheets. Note that disabling this does not
affect user styles set in [css] .
|
scripting | boolean / “app” | false |
Enable/disable JavaScript in all buffers."app" also enables JavaScript APIs that can be used to
fingerprint users (e.g. querying the window’s size.) This may achieve
better compatibility with websites that behave like applications, at the
cost of reduced privacy.For security reasons, users are encouraged to selectively enable JavaScript with [[siteconf]] instead
of using this setting.
|
images | boolean | false | Enable/disable inline image display. |
cookie | boolean / “save” | false |
Enable/disable cookies on sites. If the string “save” is specified, then cookies are also saved to external.cookie-file .
true still reads cookies.txt, but does not modify it.In Chawan, each website gets a separate cookie jar, so websites relying on cross-site cookies may not work as expected. You may use the [[siteconf]] “share-cookie-jar” setting to adjust this
behavior for specific sites.
|
referer-from | boolean | false |
Enable/disable the “Referer” header. Defaults to false. For privacy reasons, users are encouraged to leave this option disabled, only enabling it for specific sites in [[siteconf]] .
|
autofocus | boolean | false |
When set to true, elements with an “autofocus” attribute are focused on
automatically after the buffer is loaded. If scripting is enabled, this also allows scripts to focus on elements. |
meta-refresh | “never” / “always” / “ask” | “ask” |
Whether or not http-equiv=refresh meta tags should be
respected. “never” completely disables them, “always” automatically
accepts all of them, “ask” brings up a pop-up menu.
|
history | boolean | true | Whether or not browsing history should be saved to the disk. |
mark-links | boolean | false | Add numeric markers before links. In headless/dump mode, this also prints a list of URLs after the page. |
user-style | string | ““ |
A user stylesheet applied to all buffers. External stylesheets can be imported using the @import 'file.css'; syntax. Paths are
relative to the configuration directory.Nested @import is not supported yet. |
Search
Search options are to be placed in the [search]
section.
Following is a list of search options:
Name | Value | Default | Function |
---|---|---|---|
wrap | boolean | true | Whether on-page searches should wrap around the document. |
ignore-case | “auto” / boolean | “auto” |
When set to true, document-wide searches are case-insensitive by
default. When set to “auto”, searches are only case-sensitive when the
search term includes a capital letter. Note: this can also be overridden inline in the search bar (vim-style), with the escape sequences \c (ignore case) and \C (strict
case). See search mode for details.)
|
Encoding
Encoding options are to be placed in the [encoding]
section.
Following is a list of encoding options:
Name | Value | Default | Function |
---|---|---|---|
document-charset | array of charset label strings | [“utf-8”, “sjis”, “euc-jp”, “latin2”] |
List of character sets for loading documents. All listed character sets are enumerated until the document has been decoded without errors. In HTML, meta tags and the BOM may override this with a different charset, so long as the specified charset can decode the document correctly. |
display-charset | string | “auto” |
Character set for keyboard input and displaying documents. Used in dump mode as well. (This means that e.g. cha -I EUC-JP -O UTF-8 a > b is roughly equivalent
to iconv -f EUC-JP -t UTF-8 .)
|
External
External options are to be placed in the [external]
section.
Following is a list of external options:
Name | Value | Default | Function |
---|---|---|---|
tmpdir | path | {usually /tmp/cha-tmp-user} | Directory used to save temporary files. |
editor | shell command |
{usually $EDITOR }
|
External editor command. %s is substituted for the file name, %d for the line number. |
mailcap | array of paths | {see mailcap docs} | Search path for mailcap files. |
mime-types | array of paths | {see mime.types docs} | Search path for mime.types files. |
auto-mailcap | path | “auto.mailcap” |
Mailcap file for entries that are automatically executed. The “Open as” prompt also saves entries in this file. |
cgi-dir | array of paths | {see local CGI docs} | Search path for local CGI scripts. |
urimethodmap | array of paths | {see urimethodmap docs} | Search path for urimethodmap files. |
w3m-cgi-compat | boolean | false |
Enable local CGI compatibility with w3m. In short, it redirects
file:///cgi-bin/* and file:///$LIB/cgi-bin/*
to cgi-bin:* . For further details, see localcgi.md.
|
download-dir | path | {same as tmpdir} | Path to pre-fill for “Save to:” prompts. |
show-download-panel | boolean | true |
Whether the about:downloads should be shown after starting
a download.
|
copy-cmd | shell command | “xsel -bi” | Command to use for “copy to clipboard” operations. |
paste-cmd | shell command | “xsel -bo” | Command to use for “read from clipboard” operations. |
bookmark | path | “bookmark.md” | Path to the bookmark.md file. (The file it points to should have a .md extension, so that its type can be correctly deduced.) |
history-file | path | “history.uri” | Path to the history file. |
history-size | number | 100 | Maximum length of the history file. |
cookie-file | path | “cookies.txt” |
Path to the cookie file. The format is equivalent to curl’s “cookies.txt” format, except that a “jar@” part is prepended for cookies that belong in a different jar than the domain. Cookies from this file are used if “buffer.cookie” (or its equivalent siteconf override) is set to true or "save" . This means that
true sets the cookie-file to a “read-only” mode.
|
Input
Input options are to be placed in the [input]
section.
Name | Value | Function | |
---|---|---|---|
vi-numeric-prefix | boolean | true |
Whether vi-style numeric prefixes to commands should be accepted. Only applies for keybindings defined in [page] .
|
use-mouse | boolean | true |
Whether Chawan is allowed to intercept mouse clicks. The current implementation imitates w3m. |
Examples:
[input]
vi-numeric-prefix = true
[page]
# Here, the arrow function will be called with the vi numbered prefix if
# one was input, and with no argument otherwise.
# The numeric prefix can never be zero, so it is safe to test for undefined
# using the ternary operator.
G = 'n => n ? pager.gotoLine(n) : pager.cursorLastLine()'
Network
Network options are to be placed in the [network]
section.
Name | Value | Default | Function |
---|---|---|---|
max-redirect | number | 10 | Maximum number of redirections to follow. |
max-net-connections | number | 12 | Maximum number of simultaneous network connections allowed in one buffer. Further connections are held back until the number returns below the threshold. |
prepend-scheme | string | “https://” |
Prepend this to URLs passed to Chawan without a scheme. Note that local files ( file: scheme) will always be checked first;
only if this fails, Chawan will retry the request with
prepend-scheme set as the scheme.
|
prepend-https | boolean | true |
Deprecated: use prepend-scheme instead. When set to false, Chawan will act as if prepend-scheme were set to ““. |
proxy | URL | unset |
Specify a proxy for all network requests Chawan makes. Currently, the
formats http://user:pass@domain and
socks5://user:pass@domain are accepted. (Unlike in curl,
socks5h is an alias of socks5 , and DNS
requests are always tunneled.)Can be overridden by siteconf. |
default-headers | table | {omitted} | Specify a list of default headers for all HTTP(S) network requests. Can be overridden by siteconf. |
allow-http-from-file | boolean | false |
WARNING: think twice before enabling this. Allows HTTP and HTTPS requests from the file: and
stream: schemes. This is a very bad idea in general,
because it allows local files to ping remote servers (a functionality
commonly abused by HTML e-mails to track your mailbox activity.)On the other hand, it allows loading images in HTML e-mails if you don’t care about the privacy implications. |
Display
Display options are to be placed in the [display]
section.
Following is a list of display options:
Name | Value | Default | Function |
---|---|---|---|
color-mode | “monochrome” / “ansi” / “eight-bit” / “true-color” / “auto” | “auto” | Set the color mode. “auto” for automatic detection, “monochrome” for black on white, “ansi” for ansi colors, “eight-bit” for 256-color mode, and “true-color” for true colors. |
format-mode | “auto” / [“bold”, “italic”, “underline”, “reverse”, “strike”, “overline”, “blink”] | “auto” |
Specifies output formatting modes. Accepts the string “auto” or an array
of specific attributes. An empty array ([] ) disables
formatting completely.
|
no-format-mode | [“bold”, “italic”, “underline”, “reverse”, “strike”, “overline”, “blink”] | “overline” | Disable specific formatting modes. |
image-mode | “auto” / “none” / “sixel” / “kitty” | “auto” |
Specifies the image output mode. “sixel” uses sixels for output, “kitty”
uses the Kitty image display protocol, “none” disables image display
completely. “auto” tries to detect sixel or kitty support, and falls back to “none” when neither are available. This is the default setting, but you must also enable buffer.images for images to work.
|
sixel-colors | “auto” / 2..65535 | “auto” |
Only applies when display.image-mode="sixel" . Setting a
number overrides the number of sixel color registers reported by the
terminal.
|
alt-screen | “auto” / boolean | “auto” | Enable/disable the alternative screen. |
highlight-color | color | “cyan” | Set the highlight color. Both hex values and CSS color names are accepted. |
highlight-marks | boolean | true | Enable/disable highlighting of marks. |
double-width-ambiguous | boolean | false | Assume the terminal displays characters in the East Asian Ambiguous category as double-width characters. Useful when e.g. ○ occupies two cells. |
minimum-contrast | number | 100 | Specify the minimum difference between the luminance (Y) of the background and the foreground. -1 disables this function (i.e. allows black letters on black background, etc). |
force-clear | boolean | false | Force the screen to be completely cleared every time it is redrawn. |
set-title | boolean | true | Set the terminal emulator’s window title to that of the current page. |
default-background-color | “auto” / color | “auto” | Overrides the assumed background color of the terminal. “auto” leaves background color detection to Chawan. |
default-foreground-color | “auto” / color | “auto” | Sets the assumed foreground color of the terminal. “auto” leaves foreground color detection to Chawan. |
query-da1 | bool | true |
Enable/disable querying Primary Device Attributes, and with it, all
“dynamic” terminal querying. Do not alter this value unless Chawan told you so; the output will look awful. |
columns, lines, pixels-per-column, pixels-per-line | number | 80, 24, 9, 18 | Fallback values for the number of columns, lines, pixels per column, and pixels per line for the cases where it cannot be determined automatically. (For example, these values are used in dump mode.) |
force-columns, force-lines, force-pixels-per-column, force-pixels-per-line | boolean | false | Force-set columns, lines, pixels per column, or pixels per line to the fallback values provided above. |
Protocol
Protocol-related rules are to be placed in objects keyed as
[protocol.{protocol-name}]
. e.g. FTP related rules are
placed in in [protocol.ftp]
.
Name | Value | Default | Function |
---|---|---|---|
form-request | “http” / “ftp” / “data” / “mailto” | “http” | Specify which protocol to imitate when submitting forms to this protocol. |
Omnirule
The omni-bar (by default opened with C-l) can be used to perform
searches using omni-rules. These are to be specified as sub-keys to
table [omnirule]
. (The sub-key itself is ignored; you can
use anything as long it doesn’t conflict with other keys.)
Examples:
# Search using DuckDuckGo Lite.
# (This rule is included in the default config, although C-k now invokes
# Google search.)
[omnirule.ddg]
match = '^ddg:'
substitute-url = '(x) => "https://lite.duckduckgo.com/lite/?kp=-1&kd=-1&q=" + encodeURIComponent(x.split(":").slice(1).join(":"))'
# Search using Wikipedia, Firefox-style.
# The [[omnirule]] syntax introduces an anonymous omnirule; it is
# equivalent to the named one.
[[omnirule]]
match = '^@wikipedia'
substitute-url = '(x) => "https://en.wikipedia.org/wiki/Special:Search?search=" + encodeURIComponent(x.replace(/@wikipedia/, ""))'
Omnirule options:
Name | Value | Function |
---|---|---|
match | regex |
Regular expression used to match the input string. Note that websites
passed as arguments are matched as well. Note: regexes are handled according to the match mode regex handling rules. |
substitute-url | JavaScript function | A JavaScript function Chawan will pass the input string to. If a new string is returned, it will be parsed instead of the old one. |
Siteconf
Configuration options can be specified for individual sites. Entries
are to be specified as sub-keys to table [siteconf]
. (The
sub-key itself is ignored; you can use anything as long it doesn’t
conflict with other keys.)
Most siteconf options can also be specified globally; see the “overrides” field.
Examples:
# Enable cookies on the orange website for log-in.
[siteconf.hn]
url = 'https://news\.ycombinator\.com/.*'
cookie = true
# Redirect npr.org to text.npr.org.
[siteconf.npr]
host = '(www\.)?npr\.org'
rewrite-url = '''
(x) => {
x.host = "text.npr.org";
const s = x.pathname.split('/');
x.pathname = s.at(s.length > 2 ? -2 : 1);
/* No need to return; URL objects are passed by reference. */
}
'''
# Allow cookie sharing on *sr.ht domains.
[siteconf.sr-ht]
host = '(.*\.)?sr\.ht' # either 'something.sr.ht' or 'sr.ht'
cookie = true # enable cookies (read-only; use "save" to persist them)
share-cookie-jar = 'sr.ht' # use the cookie jar of 'sr.ht' for all matched hosts
# Use the "vector" skin on Wikipedia.
# The [[siteconf]] syntax introduces an anonymous siteconf; it is
# equivalent to the above ones.
[[siteconf]]
url = '^https?://[a-z]+\.wikipedia\.org/wiki/(?!.*useskin=.*)'
rewrite-url = 'x => x.searchParams.append("useskin", "vector")'
# Make imgur send us images.
[siteconf.imgur]
host = '(i\.)?imgur\.com'
default-headers = {
User-Agent = "Mozilla/5.0 chawan",
Accept = "*/*",
Accept-Encoding = "gzip, deflate",
Accept-Language = "en;q=1.0",
Pragma = "no-cache",
Cache-Control = "no-cache"
}
Siteconf options:
Name | Value | Overrides | Function |
---|---|---|---|
url | regex | n/a |
Regular expression used to match the URL. Either this or the
host option must be specified.Note: regexes are handled according to the match mode regex handling rules. |
host | regex | n/a |
Regular expression used to match the host part of the URL (i.e. domain
name/ip address.) Either this or the url option must be
specified.Note: regexes are handled according to the match mode regex handling rules. |
rewrite-url | JavaScript function | n/a | A JavaScript function Chawan will pass the site’s URL object to. If a new URL is returned, or the URL object is modified in any way, Chawan will transparently redirect the user to this new URL. |
cookie | boolean / “save” |
buffer.cookie
|
Whether loading (with “save”, also saving) cookies should be allowed for this URL. |
share-cookie-jar | host | n/a | Cookie jar to use for this domain. Useful for e.g. sharing cookies with subdomains. |
referer-from | boolean |
buffer.referer-from
|
Whether or not we should send a Referer header when opening requests originating from this domain. Simplified example: if you click a link on a.com that refers to b.com, and referer-from is true, b.com is sent “a.com” as the Referer header. |
scripting | boolean / “app” |
buffer.scripting
|
Enable/disable JavaScript execution on this site. See
buffer.scripting for details.
|
styling | boolean |
buffer.styling
|
Enable/disable author styles (CSS) on this site. |
images | boolean |
buffer.images
|
Enable/disable image display on this site. |
document-charset | charset label string |
encoding.document-charset
|
Specify the default encoding for this site. |
stylesheet | CSS stylesheet | n/a |
Specify an additional user-stylesheet for this site. Other user-stylesheets are concatenated with this to get the final user stylesheet. Note: this setting is deprecated. Please use user-style instead.
|
proxy | URL |
network.proxy
|
Specify a proxy for network requests fetching contents of this buffer. |
default-headers | table |
network.default-headers
|
Specify a list of default headers for HTTP(S) network requests to this buffer. |
insecure-ssl-no-verify | boolean | n/a |
Defaults to false. When set to true, this disables peer and hostname
verification for SSL keys on this site, like
curl --insecure would.Please do not use this unless you are absolutely sure you know what you are doing. |
autofocus | boolean |
buffer.autofocus
|
When set to true, elements with an “autofocus” attribute are focused on
automatically after the buffer is loaded. If scripting is enabled, this also allows scripts to focus on elements. |
meta-refresh | “never” / “always” / “ask” |
buffer.meta-refresh
|
Whether or not http-equiv=refresh meta tags should be
respected. “never” completely disables them, “always” automatically
accepts all of them, “ask” brings up a pop-up menu.
|
history | boolean |
buffer.history
|
Whether or not browsing history should be saved to the disk for this URL. |
mark-links | boolean |
buffer.history
|
Add numeric markers before links. |
user-style | string |
buffer.user-style
|
Specify a user style sheet specific to the site. Please refer to buffer.user-style for details.
|
Stylesheets
The [css]
section is deprecated, and will be removed in
the future. Please use buffer.user-style
instead.
(user-style
accepts inline styles by default, but can
also include external stylesheets using
@import 'file.css';
.)
Keybindings
Keybindings are to be placed in these sections:
- for pager interaction:
[page]
- for line editing:
[line]
Keybindings are configured using the syntax
'<keybinding>' = '<action>'
Where <keybinding>
is a combination of unicode
characters with or without modifiers. Modifiers are the prefixes
C-
and M-
, which add control or escape to the
keybinding respectively (essentially making M-
the same as
C-[
). Modifiers can be escaped with the \
sign.
<action>
is either a command defined in the
[cmd]
section, or a JavaScript expression. Here we only
describe the pre-defined actions in the default config; for a
description of the API, please see:
Examples:
# show change URL when Control, Escape and j are pressed
'C-M-j' = 'cmd.pager.load'
# go to the first line of the page when g is pressed twice without a preceding
# number, or to the line when a preceding number is given.
'gg' = 'cmd.buffer.gotoLineOrStart'
# JS functions and expressions are accepted too. Following replaces the
# default search engine with DuckDuckGo Lite.
# (See api.md for a list of available functions, and a discussion on how
# to add your own "namespaced" commands like above.)
'C-k' = '() => pager.load("ddg:")'
Pager actions
Default key | Name | Function |
---|---|---|
q |
cmd.pager.quit
|
Exit the browser. |
C-z |
cmd.pager.suspend
|
Temporarily suspend the browser Note: this also suspends e.g. buffer processes or CGI scripts. So if you are downloading something, that will be delayed until you restart the process. |
C-l |
cmd.pager.load
|
Open the current address in the URL bar. |
C-k |
cmd.pager.webSearch
|
Open the URL bar with an arbitrary search engine. At the moment, this is Google Search, but this may change in the future. |
M-u |
cmd.pager.dupeBuffer
|
Duplicate the current buffer by loading its source to a new buffer. |
U |
cmd.pager.reloadBuffer
|
Open a new buffer with the current buffer’s URL, replacing the current buffer. |
C-g |
cmd.pager.lineInfo
|
Display information about the current line on the status line. |
\ |
cmd.pager.toggleSource
|
If viewing an HTML buffer, open a new buffer with its source. Otherwise, open the current buffer’s contents as HTML. |
D |
cmd.pager.discardBuffer
|
Discard the current buffer, and move back to the previous/next buffer depending on what the previously viewed buffer was. |
d,, d. |
cmd.pager.discardBufferPrev ,
cmd.pager.discardBufferNext
|
Discard the current buffer, and move back to the previous/next buffer, or open the link under the cursor. |
M-d |
cmd.pager.discardTree
|
Discard all child buffers of the current buffer. |
., ,, M-,, M-., M-/ |
cmd.pager.nextBuffer , cmd.pager.prevBuffer ,
cmd.pager.prevSiblingBuffer ,
cmd.pager.nextSiblingBufer ,
cmd.pager.parentBuffer
|
Traverse the buffer tree.nextBuffer and
prevBuffer are the most intuitive, traversing the tree as
if it were a linked list.prevSiblingBuffer and
nextSiblingBuffer cycle through the buffers opened from the
same buffer.Finally, parentBuffer always returns to
the buffer the current buffer was opened from, even if e.g. the user
returns and opens another page “in between”.
|
M-c |
cmd.pager.enterCommand
|
Directly enter a JavaScript command. Note that this interacts with the pager, not the website being displayed. |
None |
cmd.pager.searchForward ,
cmd.pager.searchBackward
|
Search for a string in the current buffer, forwards or backwards. |
/, ? |
cmd.pager.isearchForward ,
cmd.pager.searchBackward
|
Incremental-search for a string, highlighting the first result, forwards or backwards. |
n, N |
cmd.pager.searchNext , cmd.pager.searchPrev
|
Jump to the nth (or if unspecified, first) next/previous search result. |
c |
cmd.pager.peek
|
Display a message of the current buffer’s URL on the status line. |
u |
cmd.pager.peekCursor
|
Display a message of the URL or title under the cursor on the status line. Multiple calls allow cycling through the two. (i.e. by default, press u once -> title, press again -> URL) |
su |
cmd.pager.showFullAlert
|
Show the last alert inside the line editor. You can also view previous ones using C-p or C-n. |
M-y |
cmd.pager.copyURL
|
Copy the current buffer’s URL to the system clipboard. |
yu |
cmd.pager.copyCursorLink
|
Copy the link under the cursor to the system clipboard. |
yI |
cmd.pager.copyCursorImage
|
Copy the URL of the image under the cursor to the system clipboard. |
M-p |
cmd.pager.gotoClipboardURL
|
Go to the URL currently on the clipboard. |
M-b |
cmd.pager.openBookmarks
|
Open the bookmark file. |
M-a |
cmd.pager.addBookmark
|
Add the current page to your bookmarks. |
Buffer actions
Note: n
in the following text refers to a number
preceding the action. e.g. in 10gg
, n = 10. If no preceding
number is input, then it is left unspecified.
Default key | Name | Function |
---|---|---|
j, k |
cmd.buffer.cursorUp , cmd.buffer.cursorDown
|
Move the cursor upwards/downwards by n lines, or if n is unspecified, by 1. |
h, l |
cmd.buffer.cursorLeft , cmd.buffer.cursorRight
|
Move the cursor to the left/right by n cells, or if n is unspecified, by 1. |
0/Home |
cmd.buffer.cursorLineBegin
|
Move the cursor to the first cell of the line. |
^ |
cmd.buffer.cursorLineTextStart
|
Move the cursor to the first non-blank character of the line. |
$/End |
cmd.buffer.cursorLineEnd
|
Move the cursor to the last cell of the line. |
w, W |
cmd.buffer.cursorNextWord ,
cmd.buffer.cursorNextViWord ,
cmd.buffer.cursorNextBigWord
|
Move the cursor to the beginning of the next word. |
None |
cmd.buffer.cursorPrevWord ,
cmd.buffer.cursorPrevViWord ,
cmd.buffer.cursorPrevBigWord
|
Move the cursor to the end of the previous word. |
e, E |
cmd.buffer.cursorWordEnd ,
cmd.buffer.cursorViWordEnd ,
cmd.buffer.cursorBigWordEnd
|
Move the cursor to the end of the current word, or if already there, to the end of the next word. |
b, B |
cmd.buffer.cursorWordBegin ,
cmd.buffer.cursorViWordBegin ,
cmd.buffer.cursorBigWordBegin
|
Move the cursor to the beginning of the current word, or if already there, to the end of the previous word. |
[, ] |
cmd.buffer.cursorPrevLink ,
cmd.buffer.cursorNextLink
|
Move the cursor to the end/beginning of the previous/next clickable element (e.g. link, input field, etc). |
{, } |
cmd.buffer.cursorPrevParagraph ,
cmd.buffer.cursorNextParagraph
|
Move the cursor to the end/beginning of the nth previous/next paragraph. |
None |
cmd.buffer.cursorRevNthLink
|
Move the cursor to the nth link of the document, counting backwards from the document’s last line. |
None |
cmd.buffer.cursorNthLink
|
Move the cursor to the nth link of the document. |
C-b, C-f, zH, zL |
cmd.buffer.pageUp , cmd.buffer.pageDown ,
cmd.buffer.pageLeft , cmd.buffer.pageRight
|
Scroll up/down/left/right by n pages, or if n is unspecified, by one page. |
C-u, C-d |
cmd.buffer.halfPageUp ,
cmd.buffer.halfPageDown ,
cmd.buffer.halfPageLeft , cmd.buffer.halfPageUp
|
Scroll up/down/left/right by n half pages, or if n is unspecified, by one page. |
K/C-y, J/C-e, zh, zl |
cmd.buffer.scrollUp , cmd.buffer.scrollDown ,
cmd.buffer.scrollLeft , cmd.buffer.scrollRight
|
Scroll up/down/left/right by n lines, or if n is unspecified, by one line. |
Enter/Return |
cmd.buffer.click
|
Click the HTML element currently under the cursor. |
I |
cmd.buffer.viewImage
|
View the image currently under the cursor in an external viewer. |
R |
cmd.buffer.reshape
|
Reshape the current buffer (=render the current page anew.) Useful if the layout is not updating even though it should have. |
r |
cmd.buffer.redraw
|
Redraw screen contents. Useful if something messed up the display. |
None (see gotoLineOrStart/End instead) |
cmd.buffer.cursorFirstLine ,
cmd.buffer.cursorLastLine
|
Move to the beginning/end in the buffer. |
H |
cmd.buffer.cursorTop
|
Move to the first line on the screen. (Equivalent to H in vi.) |
M |
cmd.buffer.cursorMiddle
|
Move to the line in the middle of the screen. (Equivalent to M in vi.) |
L |
cmd.buffer.cursorBottom
|
Move to the last line on the screen. (Equivalent to L in vi.) |
zt, z Return, zz, z., zb, z- |
cmd.buffer.raisePage ,
cmd.buffer.raisePageBegin ,
cmd.buffer.centerLine ,
cmd.buffer.centerLineBegin ,
cmd.buffer.lowerPage ,
cmd.buffer.lowerPageBegin
|
If n is specified, move cursor to line n. Then,
Begin variants also move the cursor to the line’s
first non-blank character, as the variants originating from vi do.
|
z+ |
cmd.buffer.nextPageBegin
|
If n is specified, move to the screen before the nth line and raise the page. Otherwise, go to the previous screen’s last line and raise the page. |
z^ |
cmd.buffer.previousPageBegin
|
If n is specified, move to the screen before the nth line and raise the page. Otherwise, go to the previous screen’s last line and raise the page. |
g0, gc, g$ |
cmd.buffer.cursorLeftEdge ,
cmd.buffer.cursorMiddleColumn ,
cmd.buffer.cursorRightEdge
|
Move to the first/middle/last column on the screen. |
None |
cmd.buffer.centerColumn
|
Center screen around the current column. (w3m Z .)
|
gg, G |
cmd.buffer.gotoLineOrStart ,
cmd.buffer.gotoLineOrEnd
|
If n is specified, jump to line n. Otherwise, jump to the start/end of the page. |
|, None |
cmd.buffer.gotoColumnOrBegin ,
cmd.buffer.gotoColumnOrEnd
|
If n is specified, jump to column n of the current line. Otherwise, jump to the first/last column. |
m |
cmd.buffer.mark
|
Wait for a character x and then set a mark with the ID
x .
|
`, ’ |
cmd.buffer.gotoMark , cmd.buffer.gotoMarkY
|
Wait for a character x and then jump to the mark with the
ID x (if it exists on the page).gotoMark
sets both the X and Y positions; gotoMarkY only sets the Y position.
|
: |
cmd.buffer.markURL
|
Convert URL-like strings to anchors on the current page. |
s Return |
cmd.buffer.saveLink
|
Save resource from the URL pointed to by the cursor to the disk. |
sS |
cmd.buffer.saveSource
|
Save the source of the current buffer to the disk. |
sI |
cmd.buffer.saveImage
|
Save the image currently under the cursor. |
M-i |
cmd.buffer.toggleImages
|
Toggle display of images in the current buffer. |
M-j |
cmd.buffer.toggleScripting
|
Reload the current buffer with scripting enabled/disabled. |
M-k |
cmd.buffer.toggleCookie
|
Reload the current buffer with cookies enabled/disabled. |
Line-editing actions
Default key | Name | Function |
---|---|---|
Return |
cmd.line.submit
|
Submit the line. |
C-c |
cmd.line.cancel
|
Cancel the current operation. |
C-h, C-d |
cmd.line.backspace , cmd.line.delete
|
Delete character before (backspace)/after (delete) the cursor. |
C-u, C-k |
cmd.line.clear , cmd.line.kill
|
Delete text before (clear)/after (kill) the cursor. |
C-w, M-d |
cmd.line.clearWord , cmd.line.killWord
|
Delete word before (clear)/after (kill) the cursor. |
C-b, C-f |
cmd.line.backward , cmd.line.forward
|
Move cursor backward/forward by one character. |
M-b, M-f |
cmd.line.prevWord , cmd.line.nextWord
|
Move cursor to the previous/next word by one character |
C-a/Home, C-e/End |
cmd.line.begin , cmd.line.end
|
Move cursor to the beginning/end of the line. |
C-v |
cmd.line.escape
|
Ignore keybindings for next character. |
C-p, C-n |
cmd.line.prevHist , cmd.line.nextHist
|
Jump to the previous/next history entry |
Note: to facilitate URL editing, the line editor has a different
definition of what a word is than the pager. For the line editor, a word
is either a sequence of alphanumeric characters, or any single
non-alphanumeric character. (This means that e.g. https://
consists of four words: https
, :
,
/
and /
.)
# Control+A moves the cursor to the beginning of the line.
'C-a' = 'cmd.line.begin'
# Escape+D deletes everything after the cursor until it reaches a word-breaking
# character.
'M-d' = 'cmd.line.killWord'
Appendix
Regex handling
Regular expressions are currently handled using the libregexp library from QuickJS. This means that all regular expressions work as in JavaScript.
There are two different modes of regex preprocessing in Chawan: “search” mode and “match” mode. Match mode is used for configurations (meaning in all values in this document described as “regex”). Search mode is used for the on-page search function (using searchForward/isearchForward etc.)
Match mode
Regular expressions are assumed to be exact matches, except when they start with a caret (^) sign or end with an unescaped dollar ($) sign.
In other words, the following transformations occur:
^abcd -> ^abcd (no change, only beginning is matched)
efgh$ -> efgh$ (no change, only end is matched)
^ijkl$ -> ^ijkl$ (no change, the entire line is matched)
mnop -> ^mnop$ (changed to exact match, the entire line is matched)
Match mode has no way to toggle JavaScript regex flags like
i
.
Search mode
For on-page search, the above transformations do not apply; the
search /abcd
searches for the string abcd
inside all lines.
Search mode also has some other convenience transformations (these do not work in match mode):
- The string
\c
(backslash + lower-case c) inside a search-mode regex enables case-insensitive matching. - Conversely,
\C
(backslash + capital C) disables case-insensitive matching. (Useful if you haveignore-case
set to true, which is the default.) \<
and\>
is converted to\b
(as in vi, grep, etc.)
Like match mode, search mode operates on individual lines. This means that search patterns do not match text wrapped over multiple lines.
Path handling
Rules for path handling are similar to how the shell handles strings.
- Tilde-expansion is used to determine the user’s home directory. So
e.g.
~/whatever
works. - Environment variables can be used like
$ENV_VAR
. - Relative paths are relative to the Chawan configuration directory
(i.e.
$CHA_DIR
).
Some environment variables are also exported by Chawan:
$CHA_BIN_DIR
: the directory which thecha
binary resides in. Symbolic links are automatically resolved to determine this path.$CHA_LIBEXEC_DIR
: the directory for all executables Chawan uses for operation. By default, this is$CHA_BIN_DIR/../libexec/chawan
.$CHA_DIR
: the configuration directory. (This can also be set by the user; see the top section for details.$CHA_CONFIG_DIR
is a deprecated alias for this.)
Word types
Word-based pager commands can operate with different definitions of words. Currently, these are:
- w3m words
- vi words
- Big words
w3m word
A w3m word is a sequence of alphanumeric characters. Symbols are treated in the same way as whitespace.
vi word
A vi word is a sequence of characters in the same character category. Currently, character categories are alphanumeric characters, symbols, han letters, hiragana, katakana, and hangul.
vi words may be separated by whitespace; however, vi words from separate categories do not have to be whitespace-separated. e.g. the following character sequence contains two words:
hello[]+{}@`!
Big word
A big word is a sequence of non-whitespace characters.
It is essentially the same as a w3m word, but with symbols being defined as non-whitespace.