2742 lines
150 KiB
HTML
2742 lines
150 KiB
HTML
|
<!DOCTYPE HTML>
|
|||
|
<html lang="en" class="sidebar-visible no-js light">
|
|||
|
<head>
|
|||
|
<!-- Book generated using mdBook -->
|
|||
|
<meta charset="UTF-8">
|
|||
|
<title>Zsh Line Editor - Zsh Manual</title>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<!-- Custom HTML head -->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|||
|
<meta name="description" content="">
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|||
|
<meta name="theme-color" content="#ffffff" />
|
|||
|
|
|||
|
|
|||
|
<link rel="icon" href="favicon.svg">
|
|||
|
|
|||
|
|
|||
|
<link rel="shortcut icon" href="favicon.png">
|
|||
|
|
|||
|
<link rel="stylesheet" href="css/variables.css">
|
|||
|
<link rel="stylesheet" href="css/general.css">
|
|||
|
<link rel="stylesheet" href="css/chrome.css">
|
|||
|
|
|||
|
<link rel="stylesheet" href="css/print.css" media="print">
|
|||
|
|
|||
|
|
|||
|
<!-- Fonts -->
|
|||
|
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
|
|||
|
|
|||
|
<link rel="stylesheet" href="fonts/fonts.css">
|
|||
|
|
|||
|
|
|||
|
<!-- Highlight.js Stylesheets -->
|
|||
|
<link rel="stylesheet" href="highlight.css">
|
|||
|
<link rel="stylesheet" href="tomorrow-night.css">
|
|||
|
<link rel="stylesheet" href="ayu-highlight.css">
|
|||
|
|
|||
|
<!-- Custom theme stylesheets -->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<!-- Provide site root to javascript -->
|
|||
|
<script type="text/javascript">
|
|||
|
var path_to_root = "";
|
|||
|
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
|
|||
|
</script>
|
|||
|
|
|||
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|||
|
<script type="text/javascript">
|
|||
|
try {
|
|||
|
var theme = localStorage.getItem('mdbook-theme');
|
|||
|
var sidebar = localStorage.getItem('mdbook-sidebar');
|
|||
|
|
|||
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|||
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|||
|
}
|
|||
|
|
|||
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|||
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|||
|
}
|
|||
|
} catch (e) { }
|
|||
|
</script>
|
|||
|
|
|||
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|||
|
<script type="text/javascript">
|
|||
|
var theme;
|
|||
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|||
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|||
|
var html = document.querySelector('html');
|
|||
|
html.classList.remove('no-js')
|
|||
|
html.classList.remove('light')
|
|||
|
html.classList.add(theme);
|
|||
|
html.classList.add('js');
|
|||
|
</script>
|
|||
|
|
|||
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|||
|
<script type="text/javascript">
|
|||
|
var html = document.querySelector('html');
|
|||
|
var sidebar = 'hidden';
|
|||
|
if (document.body.clientWidth >= 1080) {
|
|||
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|||
|
sidebar = sidebar || 'visible';
|
|||
|
}
|
|||
|
html.classList.remove('sidebar-visible');
|
|||
|
html.classList.add("sidebar-" + sidebar);
|
|||
|
</script>
|
|||
|
|
|||
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|||
|
<div class="sidebar-scrollbox">
|
|||
|
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html" class="active"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
|
|||
|
</div>
|
|||
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
|
|||
|
</nav>
|
|||
|
|
|||
|
<div id="page-wrapper" class="page-wrapper">
|
|||
|
|
|||
|
<div class="page">
|
|||
|
|
|||
|
<div id="menu-bar-hover-placeholder"></div>
|
|||
|
<div id="menu-bar" class="menu-bar sticky bordered">
|
|||
|
<div class="left-buttons">
|
|||
|
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|||
|
<i class="fa fa-bars"></i>
|
|||
|
</button>
|
|||
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|||
|
<i class="fa fa-paint-brush"></i>
|
|||
|
</button>
|
|||
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|||
|
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
|
|||
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|||
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|||
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|||
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|||
|
</ul>
|
|||
|
|
|||
|
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|||
|
<i class="fa fa-search"></i>
|
|||
|
</button>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<h1 class="menu-title">Zsh Manual</h1>
|
|||
|
|
|||
|
<div class="right-buttons">
|
|||
|
|
|||
|
<a href="print.html" title="Print this book" aria-label="Print this book">
|
|||
|
<i id="print-button" class="fa fa-print"></i>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<div id="search-wrapper" class="hidden">
|
|||
|
<form id="searchbar-outer" class="searchbar-outer">
|
|||
|
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|||
|
</form>
|
|||
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|||
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|||
|
<ul id="searchresults">
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|||
|
<script type="text/javascript">
|
|||
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|||
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|||
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|||
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<div id="content" class="content">
|
|||
|
<main>
|
|||
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|||
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|||
|
<p><strong>Table of Contents</strong> <em>generated with <a href="https://github.com/thlorenz/doctoc">DocToc</a></em></p>
|
|||
|
<ul>
|
|||
|
<li><a href="#18-zsh-line-editor">18 Zsh Line Editor</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#181-description">18.1 Description</a></li>
|
|||
|
<li><a href="#182-keymaps">18.2 Keymaps</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#1821-reading-commands">18.2.1 Reading Commands</a></li>
|
|||
|
<li><a href="#1822-local-keymaps">18.2.2 Local Keymaps</a></li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><a href="#183-zle-builtins">18.3 Zle Builtins</a></li>
|
|||
|
<li><a href="#184-widgets">18.4 Widgets</a></li>
|
|||
|
<li><a href="#185-user-defined-widgets">18.5 User-Defined Widgets</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#1851-special-widgets">18.5.1 Special Widgets</a></li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><a href="#186-standard-widgets">18.6 Standard Widgets</a>
|
|||
|
<ul>
|
|||
|
<li><a href="#1861-movement">18.6.1 Movement</a></li>
|
|||
|
<li><a href="#1862-history-control">18.6.2 History Control</a></li>
|
|||
|
<li><a href="#1863-modifying-text">18.6.3 Modifying Text</a></li>
|
|||
|
<li><a href="#1864-arguments">18.6.4 Arguments</a></li>
|
|||
|
<li><a href="#1865-completion">18.6.5 Completion</a></li>
|
|||
|
<li><a href="#1866-miscellaneous">18.6.6 Miscellaneous</a></li>
|
|||
|
<li><a href="#1867-text-objects">18.6.7 Text Objects</a></li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
<li><a href="#187-character-highlighting">18.7 Character Highlighting</a></li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|||
|
<p><span id="Zsh-Line-Editor"></span> <span id="Zsh-Line-Editor-1"></span></p>
|
|||
|
<h1 id="18-zsh-line-editor"><a class="header" href="#18-zsh-line-editor">18 Zsh Line Editor</a></h1>
|
|||
|
<p><span id="index-line-editor"></span>
|
|||
|
<span id="index-editor_002c-line"></span> <span id="index-ZLE-1"></span></p>
|
|||
|
<hr />
|
|||
|
<p><span id="Description-9"></span></p>
|
|||
|
<h2 id="181-description"><a class="header" href="#181-description">18.1 Description</a></h2>
|
|||
|
<p><span id="index-ZLE_002c-use-of"></span></p>
|
|||
|
<p>If the <code>ZLE</code> option is set (which it is by default in interactive
|
|||
|
shells) and the shell input is attached to the terminal, the user is
|
|||
|
able to edit command lines.</p>
|
|||
|
<p>There are two display modes. The first, multiline mode, is the default.
|
|||
|
It only works if the <code>TERM</code> parameter is set to a valid terminal type
|
|||
|
that can move the cursor up. The second, single line mode, is used if
|
|||
|
<code>TERM</code> is invalid or incapable of moving the cursor up, or if the
|
|||
|
<code>SINGLE_LINE_ZLE</code> option is set.
|
|||
|
<span id="index-SINGLE_005fLINE_005fZLE_002c-use-of"></span>
|
|||
|
<span id="index-ksh_002c-editor-mode"></span>
|
|||
|
<span id="index-editor-ksh-style"></span> This mode is similar to ksh,
|
|||
|
and uses no termcap sequences. If <code>TERM</code> is "emacs", the <code>ZLE</code> option
|
|||
|
will be unset by default.</p>
|
|||
|
<p><span id="index-BAUD_002c-use-of"></span>
|
|||
|
<span id="index-COLUMNS_002c-use-of"></span>
|
|||
|
<span id="index-LINES_002c-use-of"></span></p>
|
|||
|
<p>The parameters <code>BAUD</code>, <code>COLUMNS</code>, and <code>LINES</code> are also used by the line
|
|||
|
editor. See <a href="Parameters.html#Parameters-Used-By-The-Shell">Parameters Used By The
|
|||
|
Shell</a>.</p>
|
|||
|
<p><span id="index-zle_005fhighlight_002c-use-of"></span></p>
|
|||
|
<p>The parameter <code>zle_highlight</code> is also used by the line editor; see
|
|||
|
<a href="#Character-Highlighting">Character Highlighting</a>. Highlighting of
|
|||
|
special characters and the region between the cursor and the mark (as
|
|||
|
set with <code>set-mark-command</code> in Emacs mode, or by <code>visual-mode</code> in Vi
|
|||
|
mode) is enabled by default; consult this reference for more
|
|||
|
information. Irascible conservatives will wish to know that all
|
|||
|
highlighting may be disabled by the following setting:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle_highlight=(none)
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>In many places, references are made to the <code>numeric argument</code>. This can
|
|||
|
by default be entered in emacs mode by holding the alt key and typing a
|
|||
|
number, or pressing escape before each digit, and in vi command mode by
|
|||
|
typing the number before entering a command. Generally the numeric
|
|||
|
argument causes the next command entered to be repeated the specified
|
|||
|
number of times, unless otherwise noted below; this is implemented by
|
|||
|
the <code>digit-argument</code> widget. See also <a href="#Arguments">Arguments</a> for some
|
|||
|
other ways the numeric argument can be modified.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Keymaps"></span> <span id="Keymaps-1"></span></p>
|
|||
|
<h2 id="182-keymaps"><a class="header" href="#182-keymaps">18.2 Keymaps</a></h2>
|
|||
|
<p><span id="index-keymaps"></span> <span id="index-key-bindings"></span>
|
|||
|
<span id="index-bindings_002c-key"></span></p>
|
|||
|
<p>A keymap in ZLE contains a set of bindings between key sequences and ZLE
|
|||
|
commands. The empty key sequence cannot be bound.</p>
|
|||
|
<p>There can be any number of keymaps at any time, and each keymap has one
|
|||
|
or more names. If all of a keymap’s names are deleted, it disappears.
|
|||
|
<span id="index-bindkey_002c-use-of"></span> <code>bindkey</code> can be used to
|
|||
|
manipulate keymap names.</p>
|
|||
|
<p>Initially, there are eight keymaps:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>emacs</code><br />
|
|||
|
EMACS emulation</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>viins</code><br />
|
|||
|
vi emulation - insert mode</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>vicmd</code><br />
|
|||
|
vi emulation - command mode</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>viopp</code><br />
|
|||
|
vi emulation - operator pending</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>visual</code><br />
|
|||
|
vi emulation - selection active</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>isearch</code><br />
|
|||
|
incremental search mode</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>command</code><br />
|
|||
|
read a command name</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>.safe</code><br />
|
|||
|
fallback keymap</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>The ‘<code>.safe</code>’ keymap is special. It can never be altered, and the name
|
|||
|
can never be removed. However, it can be linked to other names, which
|
|||
|
can be removed. In the future other special keymaps may be added; users
|
|||
|
should avoid using names beginning with ‘<code>.</code>’ for their own keymaps.</p>
|
|||
|
<p><span id="index-VISUAL"></span> <span id="index-EDITOR"></span></p>
|
|||
|
<p>In addition to these names, either ‘<code>emacs</code>’ or ‘<code>viins</code>’ is also linked
|
|||
|
to the name ‘<code>main</code>’. If one of the <code>VISUAL</code> or <code>EDITOR</code> environment
|
|||
|
variables contain the string ‘<code>vi</code>’ when the shell starts up then it
|
|||
|
will be ‘<code>viins</code>’, otherwise it will be ‘<code>emacs</code>’. <code>bindkey</code>’s <code>-e</code> and
|
|||
|
<code>-v</code> options provide a convenient way to override this default choice.</p>
|
|||
|
<p>When the editor starts up, it will select the ‘<code>main</code>’ keymap. If that
|
|||
|
keymap doesn’t exist, it will use ‘<code>.safe</code>’ instead.</p>
|
|||
|
<p>In the ‘<code>.safe</code>’ keymap, each single key is bound to <code>self-insert</code>,
|
|||
|
except for ^J (line feed) and ^M (return) which are bound to
|
|||
|
<code>accept-line</code>. This is deliberately not pleasant to use; if you are
|
|||
|
using it, it means you deleted the main keymap, and you should put it
|
|||
|
back.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Reading-Commands"></span></p>
|
|||
|
<h3 id="1821-reading-commands"><a class="header" href="#1821-reading-commands">18.2.1 Reading Commands</a></h3>
|
|||
|
<p>When ZLE is reading a command from the terminal, it may read a sequence
|
|||
|
that is bound to some command and is also a prefix of a longer bound
|
|||
|
string. In this case ZLE will wait a certain time to see if more
|
|||
|
characters are typed, and if not (or they don’t match any longer string)
|
|||
|
it will execute the binding. This timeout is defined by the <code>KEYTIMEOUT</code>
|
|||
|
parameter; its default is 0.4 sec. There is no timeout if the prefix
|
|||
|
string is not itself bound to a command.</p>
|
|||
|
<p>The key timeout is also applied when ZLE is reading the bytes from a
|
|||
|
multibyte character string when it is in the appropriate mode. (This
|
|||
|
requires that the shell was compiled with multibyte mode enabled;
|
|||
|
typically also the locale has characters with the UTF-8 encoding,
|
|||
|
although any multibyte encoding known to the operating system is
|
|||
|
supported.) If the second or a subsequent byte is not read within the
|
|||
|
timeout period, the shell acts as if <code>?</code> were typed and resets the input
|
|||
|
state.</p>
|
|||
|
<p>As well as ZLE commands, key sequences can be bound to other strings, by
|
|||
|
using ‘<code>bindkey -s</code>’. When such a sequence is read, the replacement
|
|||
|
string is pushed back as input, and the command reading process starts
|
|||
|
again using these fake keystrokes. This input can itself invoke further
|
|||
|
replacement strings, but in order to detect loops the process will be
|
|||
|
stopped if there are twenty such replacements without a real command
|
|||
|
being read.</p>
|
|||
|
<p>A key sequence typed by the user can be turned into a command name for
|
|||
|
use in user-defined widgets with the <code>read-command</code> widget, described in
|
|||
|
<a href="#Miscellaneous">Miscellaneous</a> below.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Local-Keymaps"></span></p>
|
|||
|
<h3 id="1822-local-keymaps"><a class="header" href="#1822-local-keymaps">18.2.2 Local Keymaps</a></h3>
|
|||
|
<p><span id="index-local-keymaps"></span></p>
|
|||
|
<p>While for normal editing a single keymap is used exclusively, in many
|
|||
|
modes a local keymap allows for some keys to be customised. For example,
|
|||
|
in an incremental search mode, a binding in the <code>isearch</code> keymap will
|
|||
|
override a binding in the <code>main</code> keymap but all keys that are not
|
|||
|
overridden can still be used.</p>
|
|||
|
<p>If a key sequence is defined in a local keymap, it will hide a key
|
|||
|
sequence in the global keymap that is a prefix of that sequence. An
|
|||
|
example of this occurs with the binding of <code>iw</code> in <code>viopp</code> as this hides
|
|||
|
the binding of <code>i</code> in <code>vicmd</code>. However, a longer sequence in the global
|
|||
|
keymap that shares the same prefix can still apply so for example the
|
|||
|
binding of <code>^Xa</code> in the global keymap will be unaffected by the binding
|
|||
|
of <code>^Xb</code> in the local keymap.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Zle-Builtins"></span> <span id="Zle-Builtins-1"></span></p>
|
|||
|
<h2 id="183-zle-builtins"><a class="header" href="#183-zle-builtins">18.3 Zle Builtins</a></h2>
|
|||
|
<p><span id="index-zle_002c-builtin-commands"></span></p>
|
|||
|
<p>The ZLE module contains three related builtin commands. The <code>bindkey</code>
|
|||
|
command manipulates keymaps and key bindings; the <code>vared</code> command
|
|||
|
invokes ZLE on the value of a shell parameter; and the <code>zle</code> command
|
|||
|
manipulates editing widgets and allows command line access to ZLE
|
|||
|
commands from within shell functions.</p>
|
|||
|
<p><span id="index-bindkey"></span>
|
|||
|
<span id="index-keys_002c-rebinding"></span>
|
|||
|
<span id="index-rebinding-keys"></span>
|
|||
|
<span id="index-keys_002c-binding"></span>
|
|||
|
<span id="index-binding-keys"></span> <span id="index-keymaps-1"></span></p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-l</code> [ <code>-L</code> ] [ <code>keymap</code> ... ]</p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-d</code></p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-D</code> <code>keymap</code> ...</p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-A</code> <code>old-keymap new-keymap</code></p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-N</code> <code>new-keymap</code> [ <code>old-keymap</code> ]</p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-m</code></p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-r</code> <code>in-string</code> ...</p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>-s</code> <code>in-string out-string</code> ...</p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] <code>in-string command</code> ...</p>
|
|||
|
<p><code>bindkey</code> [ <code>options</code> ] [ <code>in-string</code> ]</p>
|
|||
|
<p><code>bindkey</code>’s options can be divided into three categories: keymap
|
|||
|
selection for the current command, operation selection, and others. The
|
|||
|
keymap selection options are:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>-e</code><br />
|
|||
|
Selects keymap ‘<code>emacs</code>’ for any operations by the current command,
|
|||
|
and also links ‘<code>emacs</code>’ to ‘<code>main</code>’ so that it is selected by
|
|||
|
default the next time the editor starts.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-v</code><br />
|
|||
|
Selects keymap ‘<code>viins</code>’ for any operations by the current command,
|
|||
|
and also links ‘<code>viins</code>’ to ‘<code>main</code>’ so that it is selected by
|
|||
|
default the next time the editor starts.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-a</code><br />
|
|||
|
Selects keymap ‘<code>vicmd</code>’ for any operations by the current command.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-M</code> <code>keymap</code><br />
|
|||
|
The <code>keymap</code> specifies a keymap name that is selected for any
|
|||
|
operations by the current command.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>If a keymap selection is required and none of the options above are
|
|||
|
used, the ‘<code>main</code>’ keymap is used. Some operations do not permit a
|
|||
|
keymap to be selected, namely:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>-l</code><br />
|
|||
|
List all existing keymap names; if any arguments are given, list
|
|||
|
just those keymaps.</p>
|
|||
|
<p>If the <code>-L</code> option is also used, list in the form of <code>bindkey</code>
|
|||
|
commands to create or link the keymaps. ‘<code>bindkey -lL main</code>’ shows
|
|||
|
which keymap is linked to ‘<code>main</code>’, if any, and hence if the
|
|||
|
standard emacs or vi emulation is in effect. This option does not
|
|||
|
show the <code>.safe</code> keymap because it cannot be created in that
|
|||
|
fashion; however, neither is ‘<code>bindkey -lL .safe</code>’ reported as an
|
|||
|
error, it simply outputs nothing.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-d</code><br />
|
|||
|
Delete all existing keymaps and reset to the default state.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-D</code> <code>keymap</code> ...<br />
|
|||
|
Delete the named <code>keymap</code>s.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-A</code> <code>old-keymap new-keymap</code><br />
|
|||
|
Make the <code>new-keymap</code> name an alias for <code>old-keymap</code>, so that both
|
|||
|
names refer to the same keymap. The names have equal standing; if
|
|||
|
either is deleted, the other remains. If there is already a keymap
|
|||
|
with the <code>new-keymap</code> name, it is deleted.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-N</code> <code>new-keymap</code> [ <code>old-keymap</code> ]<br />
|
|||
|
Create a new keymap, named <code>new-keymap</code>. If a keymap already has
|
|||
|
that name, it is deleted. If an <code>old-keymap</code> name is given, the new
|
|||
|
keymap is initialized to be a duplicate of it, otherwise the new
|
|||
|
keymap will be empty.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>To use a newly created keymap, it should be linked to <code>main</code>. Hence the
|
|||
|
sequence of commands to create and use a new keymap ‘<code>mymap</code>’
|
|||
|
initialized from the <code>emacs</code> keymap (which remains unchanged) is:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">bindkey -N mymap emacs
|
|||
|
bindkey -A mymap main
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>Note that while ‘<code>bindkey -A</code> <code>newmap</code> <code>main</code>’ will work when <code>newmap</code>
|
|||
|
is <code>emacs</code> or <code>viins</code>, it will not work for <code>vicmd</code>, as switching from
|
|||
|
vi insert to command mode becomes impossible.</p>
|
|||
|
<p>The following operations act on the ‘<code>main</code>’ keymap if no keymap
|
|||
|
selection option was given:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>-m</code><br />
|
|||
|
Add the built-in set of meta-key bindings to the selected keymap.
|
|||
|
Only keys that are unbound or bound to <code>self-insert</code> are affected.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-r</code> <code>in-string</code> ...<br />
|
|||
|
Unbind the specified <code>in-string</code>s in the selected keymap. This is
|
|||
|
exactly equivalent to binding the strings to <code>undefined-key</code>.</p>
|
|||
|
<p>When <code>-R</code> is also used, interpret the <code>in-string</code>s as ranges.</p>
|
|||
|
<p>When <code>-p</code> is also used, the <code>in-string</code>s specify prefixes. Any
|
|||
|
binding that has the given <code>in-string</code> as a prefix, not including
|
|||
|
the binding for the <code>in-string</code> itself, if any, will be removed. For
|
|||
|
example,</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">bindkey -rpM viins '^['
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>will remove all bindings in the vi-insert keymap beginning with an
|
|||
|
escape character (probably cursor keys), but leave the binding for
|
|||
|
the escape character itself (probably <code>vi-cmd-mode</code>). This is
|
|||
|
incompatible with the option <code>-R</code>.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-s</code> <code>in-string out-string</code> ...<br />
|
|||
|
Bind each <code>in-string</code> to each <code>out-string</code>. When <code>in-string</code> is
|
|||
|
typed, <code>out-string</code> will be pushed back and treated as input to the
|
|||
|
line editor. When <code>-R</code> is also used, interpret the <code>in-string</code>s as
|
|||
|
ranges.</p>
|
|||
|
<p>Note that both <code>in-string</code> and <code>out-string</code> are subject to the same
|
|||
|
form of interpretation, as described below.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>in-string command</code> ...<br />
|
|||
|
Bind each <code>in-string</code> to each <code>command</code>. When <code>-R</code> is used,
|
|||
|
interpret the <code>in-string</code>s as ranges.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>[ <code>in-string</code> ]<br />
|
|||
|
List key bindings. If an <code>in-string</code> is specified, the binding of
|
|||
|
that string in the selected keymap is displayed. Otherwise, all key
|
|||
|
bindings in the selected keymap are displayed. (As a special case,
|
|||
|
if the <code>-e</code> or <code>-v</code> option is used alone, the keymap is <em>not</em>
|
|||
|
displayed - the implicit linking of keymaps is the only thing that
|
|||
|
happens.)</p>
|
|||
|
<p>When the option <code>-p</code> is used, the <code>in-string</code> must be present. The
|
|||
|
listing shows all bindings which have the given key sequence as a
|
|||
|
prefix, not including any bindings for the key sequence itself.</p>
|
|||
|
<p>When the <code>-L</code> option is used, the list is in the form of <code>bindkey</code>
|
|||
|
commands to create the key bindings.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>When the <code>-R</code> option is used as noted above, a valid range consists of
|
|||
|
two characters, with an optional ‘<code>-</code>’ between them. All characters
|
|||
|
between the two specified, inclusive, are bound as specified.</p>
|
|||
|
<p>For either <code>in-string</code> or <code>out-string</code>, the following escape sequences
|
|||
|
are recognised:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>\a</code><br />
|
|||
|
bell character</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\b</code><br />
|
|||
|
backspace</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\e</code>, <code>\E</code><br />
|
|||
|
escape</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\f</code><br />
|
|||
|
form feed</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\n</code><br />
|
|||
|
linefeed (newline)</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\r</code><br />
|
|||
|
carriage return</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\t</code><br />
|
|||
|
horizontal tab</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\v</code><br />
|
|||
|
vertical tab</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\``NNN</code><br />
|
|||
|
character code in octal</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\x``NN</code><br />
|
|||
|
character code in hexadecimal</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\u``NNNN</code><br />
|
|||
|
unicode character code in hexadecimal</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\U``NNNNNNNN</code><br />
|
|||
|
unicode character code in hexadecimal</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\M</code>[<code>-</code>]<code>X</code><br />
|
|||
|
character with meta bit set</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>\C</code>[<code>-</code>]<code>X</code><br />
|
|||
|
control character</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>^``X</code><br />
|
|||
|
control character</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>In all other cases, ‘<code>\</code>’ escapes the following character. Delete is
|
|||
|
written as ‘<code>^?</code>’. Note that ‘<code>\M^?</code>’ and ‘<code>^\M?</code>’ are not the same, and
|
|||
|
that (unlike emacs), the bindings ‘<code>\M-``X</code>’ and ‘<code>\e``X</code>’ are entirely
|
|||
|
distinct, although they are initialized to the same bindings by
|
|||
|
‘<code>bindkey -m</code>’.</p>
|
|||
|
<p><span id="index-vared"></span>
|
|||
|
<span id="index-parameters_002c-editing"></span>
|
|||
|
<span id="index-editing-parameters"></span></p>
|
|||
|
<p><code>vared </code>[ <code>-Aacghe</code> ] [ <code>-p</code> <code>prompt</code> ] [ <code>-r</code> <code>rprompt</code> ]</p>
|
|||
|
<p><code> </code>[ <code>-M</code> <code>main-keymap</code> ] [ <code>-m</code> <code>vicmd-keymap</code> ]</p>
|
|||
|
<p><code> </code>[ <code>-i</code> <code>init-widget</code> ] [ <code>-f</code> <code>finish-widget</code> ]</p>
|
|||
|
<p><code> </code>[ <code>-t</code> <code>tty</code> ] <code>name</code></p>
|
|||
|
<p>The value of the parameter <code>name</code> is loaded into the edit buffer, and
|
|||
|
the line editor is invoked. When the editor exits, <code>name</code> is set to the
|
|||
|
string value returned by the editor. When the <code>-c</code> flag is given, the
|
|||
|
parameter is created if it doesn’t already exist. The <code>-a</code> flag may be
|
|||
|
given with <code>-c</code> to create an array parameter, or the <code>-A</code> flag to create
|
|||
|
an associative array. If the type of an existing parameter does not
|
|||
|
match the type to be created, the parameter is unset and recreated. The
|
|||
|
<code>-g</code> flag may be given to suppress warnings from the
|
|||
|
<code>WARN_CREATE_GLOBAL</code> and <code>WARN_NESTED_VAR</code> options.</p>
|
|||
|
<p>If an array or array slice is being edited, separator characters as
|
|||
|
defined in <code>$IFS</code> will be shown quoted with a backslash, as will
|
|||
|
backslashes themselves. Conversely, when the edited text is split into
|
|||
|
an array, a backslash quotes an immediately following separator
|
|||
|
character or backslash; no other special handling of backslashes, or any
|
|||
|
handling of quotes, is performed.</p>
|
|||
|
<p>Individual elements of existing array or associative array parameters
|
|||
|
may be edited by using subscript syntax on <code>name</code>. New elements are
|
|||
|
created automatically, even without <code>-c</code>.</p>
|
|||
|
<p>If the <code>-p</code> flag is given, the following string will be taken as the
|
|||
|
prompt to display at the left. If the <code>-r</code> flag is given, the following
|
|||
|
string gives the prompt to display at the right. If the <code>-h</code> flag is
|
|||
|
specified, the history can be accessed from ZLE. If the <code>-e</code> flag is
|
|||
|
given, typing <code>^D</code> (Control-D) on an empty line causes <code>vared</code> to exit
|
|||
|
immediately with a non-zero return value.</p>
|
|||
|
<p>The <code>-M</code> option gives a keymap to link to the <code>main</code> keymap during
|
|||
|
editing, and the <code>-m</code> option gives a keymap to link to the <code>vicmd</code>
|
|||
|
keymap during editing. For vi-style editing, this allows a pair of
|
|||
|
keymaps to override <code>viins</code> and <code>vicmd</code>. For emacs-style editing, only
|
|||
|
<code>-M</code> is normally needed but the <code>-m</code> option may still be used. On exit,
|
|||
|
the previous keymaps will be restored.</p>
|
|||
|
<p><code>Vared</code> calls the usual ‘<code>zle-line-init</code>’ and ‘<code>zle-line-finish</code>’ hooks
|
|||
|
before and after it takes control. Using the <code>-i</code> and <code>-f</code> options, it
|
|||
|
is possible to replace these with other custom widgets.</p>
|
|||
|
<p>If ‘<code>-t</code> <code>tty</code>’ is given, <code>tty</code> is the name of a terminal device to be
|
|||
|
used instead of the default <code>/dev/tty</code>. If <code>tty</code> does not refer to a
|
|||
|
terminal an error is reported.</p>
|
|||
|
<p><span id="index-zle"></span>
|
|||
|
<span id="index-widgets_002c-rebinding"></span>
|
|||
|
<span id="index-rebinding-widgets"></span>
|
|||
|
<span id="index-widgets_002c-binding"></span>
|
|||
|
<span id="index-binding-widgets"></span>
|
|||
|
<span id="index-widgets_002c-invoking"></span>
|
|||
|
<span id="index-invoking-widgets"></span>
|
|||
|
<span id="index-widgets_002c-calling"></span>
|
|||
|
<span id="index-calling-widgets"></span>
|
|||
|
<span id="index-widgets_002c-defining"></span>
|
|||
|
<span id="index-defining-widgets"></span></p>
|
|||
|
<p><code>zle</code></p>
|
|||
|
<p><code>zle</code> <code>-l</code> [ <code>-L</code> | <code>-a</code> ] [ <code>string</code> ... ]</p>
|
|||
|
<p><code>zle</code> <code>-D</code> <code>widget</code> ...</p>
|
|||
|
<p><code>zle</code> <code>-A</code> <code>old-widget</code> <code>new-widget</code></p>
|
|||
|
<p><code>zle</code> <code>-N</code> <code>widget</code> [ <code>function</code> ]</p>
|
|||
|
<p><code>zle</code> <code>-f</code> <code>flag</code> [ <code>flag</code>... ]</p>
|
|||
|
<p><code>zle</code> <code>-C</code> <code>widget</code> <code>completion-widget</code> <code>function</code></p>
|
|||
|
<p><code>zle</code> <code>-R</code> [ <code>-c</code> ] [ <code>display-string</code> ] [ <code>string</code> ... ]</p>
|
|||
|
<p><code>zle</code> <code>-M</code> <code>string</code></p>
|
|||
|
<p><code>zle</code> <code>-U</code> <code>string</code></p>
|
|||
|
<p><code>zle</code> <code>-K</code> <code>keymap</code></p>
|
|||
|
<p><code>zle</code> <code>-F</code> [ <code>-L</code> | <code>-w</code> ] [ <code>fd</code> [ <code>handler</code> ] ]</p>
|
|||
|
<p><code>zle</code> <code>-I</code></p>
|
|||
|
<p><code>zle</code> <code>-T</code> [ <code>tc</code> <code>function</code> | <code>-r</code> <code>tc</code> | <code>-L</code> ]</p>
|
|||
|
<p><code>zle</code> <code>widget</code> [ <code>-n</code> <code>num</code> ] [ <code>-Nw</code> ] [ <code>-K</code> <code>keymap</code> ] <code>args</code>
|
|||
|
...</p>
|
|||
|
<p>The <code>zle</code> builtin performs a number of different actions concerning ZLE.</p>
|
|||
|
<p>With no options and no arguments, only the return status will be set. It
|
|||
|
is zero if ZLE is currently active and widgets could be invoked using
|
|||
|
this builtin command and non-zero otherwise. Note that even if non-zero
|
|||
|
status is returned, zle may still be active as part of the completion
|
|||
|
system; this does not allow direct calls to ZLE widgets.</p>
|
|||
|
<p>Otherwise, which operation it performs depends on its options:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>-l</code> [ <code>-L</code> | <code>-a</code> ] [ <code>string</code> ]<br />
|
|||
|
List all existing user-defined widgets. If the <code>-L</code> option is used,
|
|||
|
list in the form of <code>zle</code> commands to create the widgets.</p>
|
|||
|
<p>When combined with the <code>-a</code> option, all widget names are listed,
|
|||
|
including the builtin ones. In this case the <code>-L</code> option is ignored.</p>
|
|||
|
<p>If at least one <code>string</code> is given, and <code>-a</code> is present or <code>-L</code> is
|
|||
|
not used, nothing will be printed. The return status will be zero if
|
|||
|
all <code>string</code>s are names of existing widgets and non-zero if at least
|
|||
|
one <code>string</code> is not a name of a defined widget. If <code>-a</code> is also
|
|||
|
present, all widget names are used for the comparison including
|
|||
|
builtin widgets, else only user-defined widgets are used.</p>
|
|||
|
<p>If at least one <code>string</code> is present and the <code>-L</code> option is used,
|
|||
|
user-defined widgets matching any <code>string</code> are listed in the form of
|
|||
|
<code>zle</code> commands to create the widgets.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-D</code> <code>widget</code> ...<br />
|
|||
|
Delete the named <code>widget</code>s.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-A</code> <code>old-widget</code> <code>new-widget</code><br />
|
|||
|
Make the <code>new-widget</code> name an alias for <code>old-widget</code>, so that both
|
|||
|
names refer to the same widget. The names have equal standing; if
|
|||
|
either is deleted, the other remains. If there is already a widget
|
|||
|
with the <code>new-widget</code> name, it is deleted.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-N</code> <code>widget</code> [ <code>function</code> ]<br />
|
|||
|
Create a user-defined widget. If there is already a widget with the
|
|||
|
specified name, it is overwritten. When the new widget is invoked
|
|||
|
from within the editor, the specified shell <code>function</code> is called. If
|
|||
|
no function name is specified, it defaults to the same name as the
|
|||
|
widget. For further information, see <a href="#Zle-Widgets">Widgets</a>.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-f</code> <code>flag</code> [ <code>flag</code>... ]<br />
|
|||
|
Set various flags on the running widget. Possible values for <code>flag</code>
|
|||
|
are:</p>
|
|||
|
<p><code>yank</code> for indicating that the widget has yanked text into the
|
|||
|
buffer. If the widget is wrapping an existing internal widget, no
|
|||
|
further action is necessary, but if it has inserted the text
|
|||
|
manually, then it should also take care to set <code>YANK_START</code> and
|
|||
|
<code>YANK_END</code> correctly. <code>yankbefore</code> does the same but is used when
|
|||
|
the yanked text appears after the cursor.</p>
|
|||
|
<p><code>kill</code> for indicating that text has been killed into the cutbuffer.
|
|||
|
When repeatedly invoking a kill widget, text is appended to the
|
|||
|
cutbuffer instead of replacing it, but when wrapping such widgets,
|
|||
|
it is necessary to call ‘<code>zle -f kill</code>’ to retain this effect.</p>
|
|||
|
<p><code>vichange</code> for indicating that the widget represents a vi change
|
|||
|
that can be repeated as a whole with ‘<code>vi-repeat-change</code>’. The flag
|
|||
|
should be set early in the function before inspecting the value of
|
|||
|
<code>NUMERIC</code> or invoking other widgets. This has no effect for a widget
|
|||
|
invoked from insert mode. If insert mode is active when the widget
|
|||
|
finishes, the change extends until next returning to command mode.</p>
|
|||
|
<p><span id="index-completion-widgets_002c-creating"></span></p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-C</code> <code>widget</code> <code>completion-widget</code> <code>function</code><br />
|
|||
|
Create a user-defined completion widget named <code>widget</code>. The
|
|||
|
completion widget will behave like the built-in completion-widget
|
|||
|
whose name is given as <code>completion-widget</code>. To generate the
|
|||
|
completions, the shell function <code>function</code> will be called. For
|
|||
|
further information, see <a href="Completion-Widgets.html#Completion-Widgets">Completion
|
|||
|
Widgets</a>.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-R</code> [ <code>-c</code> ] [ <code>display-string</code> ] [ <code>string</code> ... ]<br />
|
|||
|
Redisplay the command line; this is to be called from within a
|
|||
|
user-defined widget to allow changes to become visible. If a
|
|||
|
<code>display-string</code> is given and not empty, this is shown in the status
|
|||
|
line (immediately below the line being edited).</p>
|
|||
|
<p>If the optional <code>string</code>s are given they are listed below the prompt
|
|||
|
in the same way as completion lists are printed. If no <code>string</code>s are
|
|||
|
given but the <code>-c</code> option is used such a list is cleared.</p>
|
|||
|
<p>Note that this option is only useful for widgets that do not exit
|
|||
|
immediately after using it because the strings displayed will be
|
|||
|
erased immediately after return from the widget.</p>
|
|||
|
<p>This command can safely be called outside user defined widgets; if
|
|||
|
zle is active, the display will be refreshed, while if zle is not
|
|||
|
active, the command has no effect. In this case there will usually
|
|||
|
be no other arguments.</p>
|
|||
|
<p>The status is zero if zle was active, else one.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-M</code> <code>string</code><br />
|
|||
|
As with the <code>-R</code> option, the <code>string</code> will be displayed below the
|
|||
|
command line; unlike the <code>-R</code> option, the string will not be put
|
|||
|
into the status line but will instead be printed normally below the
|
|||
|
prompt. This means that the <code>string</code> will still be displayed after
|
|||
|
the widget returns (until it is overwritten by subsequent commands).</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-U</code> <code>string</code><br />
|
|||
|
This pushes the characters in the <code>string</code> onto the input stack of
|
|||
|
ZLE. After the widget currently executed finishes ZLE will behave as
|
|||
|
if the characters in the <code>string</code> were typed by the user.</p>
|
|||
|
<p>As ZLE uses a stack, if this option is used repeatedly the last
|
|||
|
string pushed onto the stack will be processed first. However, the
|
|||
|
characters in each <code>string</code> will be processed in the order in which
|
|||
|
they appear in the string.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-K</code> <code>keymap</code><br />
|
|||
|
Selects the keymap named <code>keymap</code>. An error message will be
|
|||
|
displayed if there is no such keymap.</p>
|
|||
|
<p>This keymap selection affects the interpretation of following
|
|||
|
keystrokes within this invocation of ZLE. Any following invocation
|
|||
|
(e.g., the next command line) will start as usual with the ‘<code>main</code>’
|
|||
|
keymap selected.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-F</code> [ <code>-L</code> | <code>-w</code> ] [ <code>fd</code> [ <code>handler</code> ] ]<br />
|
|||
|
Only available if your system supports one of the ‘poll’ or ‘select’
|
|||
|
system calls; most modern systems do.</p>
|
|||
|
<p>Installs <code>handler</code> (the name of a shell function) to handle input
|
|||
|
from file descriptor <code>fd</code>. Installing a handler for an <code>fd</code> which is
|
|||
|
already handled causes the existing handler to be replaced. Any
|
|||
|
number of handlers for any number of readable file descriptors may
|
|||
|
be installed. Note that zle makes no attempt to check whether this
|
|||
|
<code>fd</code> is actually readable when installing the handler. The user must
|
|||
|
make their own arrangements for handling the file descriptor when
|
|||
|
zle is not active.</p>
|
|||
|
<p>When zle is attempting to read data, it will examine both the
|
|||
|
terminal and the list of handled <code>fd</code>’s. If data becomes available
|
|||
|
on a handled <code>fd</code>, zle calls <code>handler</code> with the fd which is ready
|
|||
|
for reading as the first argument. Under normal circumstances this
|
|||
|
is the only argument, but if an error was detected, a second
|
|||
|
argument provides details: ‘<code>hup</code>’ for a disconnect, ‘<code>nval</code>’ for a
|
|||
|
closed or otherwise invalid descriptor, or ‘<code>err</code>’ for any other
|
|||
|
condition. Systems that support only the ‘select’ system call always
|
|||
|
use ‘<code>err</code>’.</p>
|
|||
|
<p>If the option <code>-w</code> is also given, the <code>handler</code> is instead a line
|
|||
|
editor widget, typically a shell function made into a widget using
|
|||
|
‘<code>zle -N</code>’. In that case <code>handler</code> can use all the facilities of
|
|||
|
zle to update the current editing line. Note, however, that as
|
|||
|
handling <code>fd</code> takes place at a low level changes to the display will
|
|||
|
not automatically appear; the widget should call ‘<code>zle -R</code>’ to force
|
|||
|
redisplay. As of this writing, widget handlers only support a single
|
|||
|
argument and thus are never passed a string for error state, so
|
|||
|
widgets must be prepared to test the descriptor themselves.</p>
|
|||
|
<p>If either type of handler produces output to the terminal, it should
|
|||
|
call ‘<code>zle -I</code>’ before doing so (see below). Handlers should not
|
|||
|
attempt to read from the terminal.</p>
|
|||
|
<p>If no <code>handler</code> is given, but an <code>fd</code> is present, any handler for
|
|||
|
that <code>fd</code> is removed. If there is none, an error message is printed
|
|||
|
and status 1 is returned.</p>
|
|||
|
<p>If no arguments are given, or the <code>-L</code> option is supplied, a list of
|
|||
|
handlers is printed in a form which can be stored for later
|
|||
|
execution.</p>
|
|||
|
<p>An <code>fd</code> (but not a <code>handler</code>) may optionally be given with the <code>-L</code>
|
|||
|
option; in this case, the function will list the handler if any,
|
|||
|
else silently return status 1.</p>
|
|||
|
<p>Note that this feature should be used with care. Activity on one of
|
|||
|
the <code>fd</code>’s which is not properly handled can cause the terminal to
|
|||
|
become unusable. Removing an <code>fd</code> handler from within a signal trap
|
|||
|
may cause</p>
|
|||
|
<p>Here is a simple example of using this feature. A connection to a
|
|||
|
remote TCP port is created using the ztcp command; see <a href="Zsh-Modules.html#The-zsh_002fnet_002ftcp-Module">The
|
|||
|
zsh/net/tcp
|
|||
|
Module</a>. Then a
|
|||
|
handler is installed which simply prints out any data which arrives
|
|||
|
on this connection. Note that ‘select’ will indicate that the file
|
|||
|
descriptor needs handling if the remote side has closed the
|
|||
|
connection; we handle that by testing for a failed read.</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">if ztcp pwspc 2811; then
|
|||
|
tcpfd=$REPLY
|
|||
|
handler() {
|
|||
|
zle -I
|
|||
|
local line
|
|||
|
if ! read -r line <&$1; then
|
|||
|
# select marks this fd if we reach EOF,
|
|||
|
# so handle this specially.
|
|||
|
print "[Read on fd $1 failed, removing.]" >&2
|
|||
|
zle -F $1
|
|||
|
return 1
|
|||
|
fi
|
|||
|
print -r - $line
|
|||
|
}
|
|||
|
zle -F $tcpfd handler
|
|||
|
fi
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-I</code><br />
|
|||
|
Unusually, this option is most useful outside ordinary widget
|
|||
|
functions, though it may be used within if normal output to the
|
|||
|
terminal is required. It invalidates the current zle display in
|
|||
|
preparation for output; typically this will be from a trap function.
|
|||
|
It has no effect if zle is not active. When a trap exits, the shell
|
|||
|
checks to see if the display needs restoring, hence the following
|
|||
|
will print output in such a way as not to disturb the line being
|
|||
|
edited:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">TRAPUSR1() {
|
|||
|
# Invalidate zle display
|
|||
|
[[ -o zle ]] && zle -I
|
|||
|
# Show output
|
|||
|
print Hello
|
|||
|
}
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>In general, the trap function may need to test whether zle is active
|
|||
|
before using this method (as shown in the example), since the
|
|||
|
<code>zsh/zle</code> module may not even be loaded; if it is not, the command
|
|||
|
can be skipped.</p>
|
|||
|
<p>It is possible to call ‘<code>zle -I</code>’ several times before control is
|
|||
|
returned to the editor; the display will only be invalidated the
|
|||
|
first time to minimise disruption.</p>
|
|||
|
<p>Note that there are normally better ways of manipulating the display
|
|||
|
from within zle widgets; see, for example, ‘<code>zle -R</code>’ above.</p>
|
|||
|
<p>The returned status is zero if zle was invalidated, even though this
|
|||
|
may have been by a previous call to ‘<code>zle -I</code>’ or by a system
|
|||
|
notification. To test if a zle widget may be called at this point,
|
|||
|
execute <code>zle</code> with no arguments and examine the return status.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>-T</code><br />
|
|||
|
This is used to add, list or remove internal transformations on the
|
|||
|
processing performed by the line editor. It is typically used only
|
|||
|
for debugging or testing and is therefore of little interest to the
|
|||
|
general user.</p>
|
|||
|
<p>‘<code>zle -T</code> <code>transformation</code> <code>func</code>’ specifies that the given
|
|||
|
<code>transformation</code> (see below) is effected by shell function <code>func</code>.</p>
|
|||
|
<p>‘<code>zle -Tr</code> <code>transformation</code>’ removes the given <code>transformation</code> if
|
|||
|
it was present (it is not an error if none was).</p>
|
|||
|
<p>‘<code>zle -TL</code>’ can be used to list all transformations currently in
|
|||
|
operation.</p>
|
|||
|
<p>Currently the only transformation is <code>tc</code>. This is used instead of
|
|||
|
outputting termcap codes to the terminal. When the transformation is
|
|||
|
in operation the shell function is passed the termcap code that
|
|||
|
would be output as its first argument; if the operation required a
|
|||
|
numeric argument, that is passed as a second argument. The function
|
|||
|
should set the shell variable <code>REPLY</code> to the transformed termcap
|
|||
|
code. Typically this is used to produce some simply formatted
|
|||
|
version of the code and optional argument for debugging or testing.
|
|||
|
Note that this transformation is not applied to other non-printing
|
|||
|
characters such as carriage returns and newlines.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>widget</code> [ <code>-n</code> <code>num</code> ] [ <code>-Nw</code> ] [ <code>-K</code> <code>keymap</code> ] <code>args</code>
|
|||
|
...<br />
|
|||
|
Invoke the specified <code>widget</code>. This can only be done when ZLE is
|
|||
|
active; normally this will be within a user-defined widget.</p>
|
|||
|
<p>With the options <code>-n</code> and <code>-N</code>, the current numeric argument will be
|
|||
|
saved and then restored after the call to <code>widget</code>; ‘<code>-n</code> <code>num</code>’
|
|||
|
sets the numeric argument temporarily to <code>num</code>, while ‘<code>-N</code>’ sets it
|
|||
|
to the default, i.e. as if there were none.</p>
|
|||
|
<p>With the option <code>-K</code>, <code>keymap</code> will be used as the current keymap
|
|||
|
during the execution of the widget. The previous keymap will be
|
|||
|
restored when the widget exits.</p>
|
|||
|
<p>Normally, calling a widget in this way does not set the special
|
|||
|
parameter <code>WIDGET</code> and related parameters, so that the environment
|
|||
|
appears as if the top-level widget called by the user were still
|
|||
|
active. With the option <code>-w</code>, <code>WIDGET</code> and related parameters are
|
|||
|
set to reflect the widget being executed by the <code>zle</code> call.</p>
|
|||
|
<p>Any further arguments will be passed to the widget; note that as
|
|||
|
standard argument handling is performed, any general argument list
|
|||
|
should be preceded by <code>-``-</code>. If it is a shell function, these are
|
|||
|
passed down as positional parameters; for builtin widgets it is up
|
|||
|
to the widget in question what it does with them. Currently
|
|||
|
arguments are only handled by the incremental-search commands, the
|
|||
|
<code>history-search-forward</code> and <code>-backward</code> and the corresponding
|
|||
|
functions prefixed by <code>vi-</code>, and by <code>universal-argument</code>. No error
|
|||
|
is flagged if the command does not use the arguments, or only uses
|
|||
|
some of them.</p>
|
|||
|
<p>The return status reflects the success or failure of the operation
|
|||
|
carried out by the widget, or if it is a user-defined widget the
|
|||
|
return status of the shell function.</p>
|
|||
|
<p>A non-zero return status causes the shell to beep when the widget
|
|||
|
exits, unless the <code>BEEP</code> options was unset or the widget was called
|
|||
|
via the <code>zle</code> command. Thus if a user defined widget requires an
|
|||
|
immediate beep, it should call the <code>beep</code> widget directly.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<hr />
|
|||
|
<p><span id="Zle-Widgets"></span> <span id="Widgets-1"></span></p>
|
|||
|
<h2 id="184-widgets"><a class="header" href="#184-widgets">18.4 Widgets</a></h2>
|
|||
|
<p><span id="index-widgets"></span></p>
|
|||
|
<p>All actions in the editor are performed by ‘widgets’. A widget’s job is
|
|||
|
simply to perform some small action. The ZLE commands that key sequences
|
|||
|
in keymaps are bound to are in fact widgets. Widgets can be user-defined
|
|||
|
or built in.</p>
|
|||
|
<p>The standard widgets built into ZLE are listed in Standard Widgets
|
|||
|
below. Other built-in widgets can be defined by other modules (see <a href="Zsh-Modules.html#Zsh-Modules">Zsh
|
|||
|
Modules</a>). Each built-in widget has two
|
|||
|
names: its normal canonical name, and the same name preceded by a ‘<code>.</code>’.
|
|||
|
The ‘<code>.</code>’ name is special: it can’t be rebound to a different widget.
|
|||
|
This makes the widget available even when its usual name has been
|
|||
|
redefined.</p>
|
|||
|
<p>User-defined widgets are defined using ‘<code>zle -N</code>’, and implemented as
|
|||
|
shell functions. When the widget is executed, the corresponding shell
|
|||
|
function is executed, and can perform editing (or other) actions. It is
|
|||
|
recommended that user-defined widgets should not have names starting
|
|||
|
with ‘<code>.</code>’.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="User_002dDefined-Widgets"></span></p>
|
|||
|
<h2 id="185-user-defined-widgets"><a class="header" href="#185-user-defined-widgets">18.5 User-Defined Widgets</a></h2>
|
|||
|
<p><span id="index-widgets_002c-user_002ddefined"></span></p>
|
|||
|
<p>User-defined widgets, being implemented as shell functions, can execute
|
|||
|
any normal shell command. They can also run other widgets (whether
|
|||
|
built-in or user-defined) using the <code>zle</code> builtin command. The standard
|
|||
|
input of the function is redirected from /dev/null to prevent external
|
|||
|
commands from unintentionally blocking ZLE by reading from the terminal,
|
|||
|
but <code>read -k</code> or <code>read -q</code> can be used to read characters. Finally, they
|
|||
|
can examine and edit the ZLE buffer being edited by reading and setting
|
|||
|
the special parameters described below.</p>
|
|||
|
<p><span id="index-parameters_002c-editor"></span>
|
|||
|
<span id="index-parameters_002c-zle"></span></p>
|
|||
|
<p>These special parameters are always available in widget functions, but
|
|||
|
are not in any way special outside ZLE. If they have some normal value
|
|||
|
outside ZLE, that value is temporarily inaccessible, but will return
|
|||
|
when the widget function exits. These special parameters in fact have
|
|||
|
local scope, like parameters created in a function using <code>local</code>.</p>
|
|||
|
<p>Inside completion widgets and traps called while ZLE is active, these
|
|||
|
parameters are available read-only.</p>
|
|||
|
<p>Note that the parameters appear as local to any ZLE widget in which they
|
|||
|
appear. Hence if it is desired to override them this needs to be done
|
|||
|
within a nested function:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">widget-function() {
|
|||
|
# $WIDGET here refers to the special variable
|
|||
|
# that is local inside widget-function
|
|||
|
() {
|
|||
|
# This anonymous nested function allows WIDGET
|
|||
|
# to be used as a local variable. The -h
|
|||
|
# removes the special status of the variable.
|
|||
|
local -h WIDGET
|
|||
|
}
|
|||
|
}
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p><span id="index-BUFFER"></span></p>
|
|||
|
<p><code>BUFFER</code> (scalar)</p>
|
|||
|
<p>The entire contents of the edit buffer. If it is written to, the cursor
|
|||
|
remains at the same offset, unless that would put it outside the buffer.</p>
|
|||
|
<p><span id="index-BUFFERLINES"></span></p>
|
|||
|
<p><code>BUFFERLINES</code> (integer)</p>
|
|||
|
<p>The number of screen lines needed for the edit buffer currently
|
|||
|
displayed on screen (i.e. without any changes to the preceding
|
|||
|
parameters done after the last redisplay); read-only.</p>
|
|||
|
<p><span id="index-CONTEXT"></span></p>
|
|||
|
<p><code>CONTEXT</code> (scalar)</p>
|
|||
|
<p>The context in which zle was called to read a line; read-only. One of
|
|||
|
the values:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>start</code><br />
|
|||
|
The start of a command line (at prompt <code>PS1</code>).</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>cont</code><br />
|
|||
|
A continuation to a command line (at prompt <code>PS2</code>).</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>select</code><br />
|
|||
|
In a <code>select</code> loop (at prompt <code>PS3</code>).</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>vared</code><br />
|
|||
|
Editing a variable in <code>vared</code>.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p><span id="index-CURSOR"></span></p>
|
|||
|
<p><code>CURSOR</code> (integer)</p>
|
|||
|
<p>The offset of the cursor, within the edit buffer. This is in the range 0
|
|||
|
to <code>$#BUFFER</code>, and is by definition equal to <code>$#LBUFFER</code>. Attempts to
|
|||
|
move the cursor outside the buffer will result in the cursor being moved
|
|||
|
to the appropriate end of the buffer.</p>
|
|||
|
<p><span id="index-CUTBUFFER"></span></p>
|
|||
|
<p><code>CUTBUFFER</code> (scalar)</p>
|
|||
|
<p>The last item cut using one of the ‘<code>kill-</code>’ commands; the string which
|
|||
|
the next yank would insert in the line. Later entries in the kill ring
|
|||
|
are in the array <code>killring</code>. Note that the command ‘<code>zle copy-region-as-kill</code> <code>string</code>’ can be used to set the text of the cut
|
|||
|
buffer from a shell function and cycle the kill ring in the same way as
|
|||
|
interactively killing text.</p>
|
|||
|
<p><span id="index-HISTNO"></span></p>
|
|||
|
<p><code>HISTNO</code> (integer)</p>
|
|||
|
<p>The current history number. Setting this has the same effect as moving
|
|||
|
up or down in the history to the corresponding history line. An attempt
|
|||
|
to set it is ignored if the line is not stored in the history. Note this
|
|||
|
is not the same as the parameter <code>HISTCMD</code>, which always gives the
|
|||
|
number of the history line being added to the main shell’s history.
|
|||
|
<code>HISTNO</code> refers to the line being retrieved within zle.</p>
|
|||
|
<p><span id="index-ISEARCHMATCH_005fACTIVE"></span>
|
|||
|
<span id="index-ISEARCHMATCH_005fSTART"></span>
|
|||
|
<span id="index-ISEARCHMATCH_005fEND"></span></p>
|
|||
|
<p><code>ISEARCHMATCH_ACTIVE</code> (integer)</p>
|
|||
|
<p><code>ISEARCHMATCH_START</code> (integer)</p>
|
|||
|
<p><code>ISEARCHMATCH_END</code> (integer)</p>
|
|||
|
<p><code>ISEARCHMATCH_ACTIVE</code> indicates whether a part of the <code>BUFFER</code> is
|
|||
|
currently matched by an incremental search pattern. <code>ISEARCHMATCH_START</code>
|
|||
|
and <code>ISEARCHMATCH_END</code> give the location of the matched part and are in
|
|||
|
the same units as <code>CURSOR</code>. They are only valid for reading when
|
|||
|
<code>ISEARCHMATCH_ACTIVE</code> is non-zero.</p>
|
|||
|
<p>All parameters are read-only.</p>
|
|||
|
<p><span id="index-KEYMAP"></span></p>
|
|||
|
<p><code>KEYMAP</code> (scalar)</p>
|
|||
|
<p>The name of the currently selected keymap; read-only.</p>
|
|||
|
<p><span id="index-KEYS"></span></p>
|
|||
|
<p><code>KEYS</code> (scalar)</p>
|
|||
|
<p>The keys typed to invoke this widget, as a literal string; read-only.</p>
|
|||
|
<p><span id="index-KEYS_005fQUEUED_005fCOUNT"></span></p>
|
|||
|
<p><code>KEYS_QUEUED_COUNT</code> (integer)</p>
|
|||
|
<p>The number of bytes pushed back to the input queue and therefore
|
|||
|
available for reading immediately before any I/O is done; read-only. See
|
|||
|
also <code>PENDING</code>; the two values are distinct.</p>
|
|||
|
<p><span id="index-killring"></span></p>
|
|||
|
<p><code>killring</code> (array)</p>
|
|||
|
<p>The array of previously killed items, with the most recently killed
|
|||
|
first. This gives the items that would be retrieved by a <code>yank-pop</code> in
|
|||
|
the same order. Note, however, that the most recently killed item is in
|
|||
|
<code>$CUTBUFFER</code>; <code>$killring</code> shows the array of previous entries.</p>
|
|||
|
<p>The default size for the kill ring is eight, however the length may be
|
|||
|
changed by normal array operations. Any empty string in the kill ring is
|
|||
|
ignored by the <code>yank-pop</code> command, hence the size of the array
|
|||
|
effectively sets the maximum length of the kill ring, while the number
|
|||
|
of non-zero strings gives the current length, both as seen by the user
|
|||
|
at the command line.</p>
|
|||
|
<p><span id="index-LASTABORTEDSEARCH"></span></p>
|
|||
|
<p><code>LASTABORTEDSEARCH</code> (scalar)</p>
|
|||
|
<p>The last search string used by an interactive search that was aborted by
|
|||
|
the user (status 3 returned by the search widget).</p>
|
|||
|
<p><span id="index-LASTSEARCH"></span></p>
|
|||
|
<p><code>LASTSEARCH</code> (scalar)</p>
|
|||
|
<p>The last search string used by an interactive search; read-only. This is
|
|||
|
set even if the search failed (status 0, 1 or 2 returned by the search
|
|||
|
widget), but not if it was aborted by the user.</p>
|
|||
|
<p><span id="index-LASTWIDGET"></span></p>
|
|||
|
<p><code>LASTWIDGET</code> (scalar)</p>
|
|||
|
<p>The name of the last widget that was executed; read-only.</p>
|
|||
|
<p><span id="index-LBUFFER"></span></p>
|
|||
|
<p><code>LBUFFER</code> (scalar)</p>
|
|||
|
<p>The part of the buffer that lies to the left of the cursor position. If
|
|||
|
it is assigned to, only that part of the buffer is replaced, and the
|
|||
|
cursor remains between the new <code>$LBUFFER</code> and the old <code>$RBUFFER</code>.</p>
|
|||
|
<p><span id="index-MARK"></span></p>
|
|||
|
<p><code>MARK</code> (integer)</p>
|
|||
|
<p>Like <code>CURSOR</code>, but for the mark. With vi-mode operators that wait for a
|
|||
|
movement command to select a region of text, setting <code>MARK</code> allows the
|
|||
|
selection to extend in both directions from the initial cursor position.</p>
|
|||
|
<p><span id="index-NUMERIC"></span></p>
|
|||
|
<p><code>NUMERIC</code> (integer)</p>
|
|||
|
<p>The numeric argument. If no numeric argument was given, this parameter
|
|||
|
is unset. When this is set inside a widget function, builtin widgets
|
|||
|
called with the <code>zle</code> builtin command will use the value assigned. If it
|
|||
|
is unset inside a widget function, builtin widgets called behave as if
|
|||
|
no numeric argument was given.</p>
|
|||
|
<p><span id="index-PENDING"></span></p>
|
|||
|
<p><code>PENDING</code> (integer)</p>
|
|||
|
<p>The number of bytes pending for input, i.e. the number of bytes which
|
|||
|
have already been typed and can immediately be read. On systems where
|
|||
|
the shell is not able to get this information, this parameter will
|
|||
|
always have a value of zero. Read-only. See also <code>KEYS_QUEUED_COUNT</code>;
|
|||
|
the two values are distinct.</p>
|
|||
|
<p><span id="index-PREBUFFER"></span></p>
|
|||
|
<p><code>PREBUFFER</code> (scalar)</p>
|
|||
|
<p>In a multi-line input at the secondary prompt, this read-only parameter
|
|||
|
contains the contents of the lines before the one the cursor is
|
|||
|
currently in.</p>
|
|||
|
<p><span id="index-PREDISPLAY"></span></p>
|
|||
|
<p><code>PREDISPLAY</code> (scalar)</p>
|
|||
|
<p>does not have to be a complete line; to display a complete line, a
|
|||
|
newline must be appended explicitly. The text is reset on each new
|
|||
|
invocation (but not recursive invocation) of zle.</p>
|
|||
|
<p><span id="index-POSTDISPLAY"></span></p>
|
|||
|
<p><code>POSTDISPLAY</code> (scalar)</p>
|
|||
|
<p>does not have to be a complete line; to display a complete line, a
|
|||
|
newline must be prepended explicitly. The text is reset on each new
|
|||
|
invocation (but not recursive invocation) of zle.</p>
|
|||
|
<p><span id="index-RBUFFER"></span></p>
|
|||
|
<p><code>RBUFFER</code> (scalar)</p>
|
|||
|
<p>The part of the buffer that lies to the right of the cursor position. If
|
|||
|
it is assigned to, only that part of the buffer is replaced, and the
|
|||
|
cursor remains between the old <code>$LBUFFER</code> and the new <code>$RBUFFER</code>.</p>
|
|||
|
<p><span id="index-REGION_005fACTIVE"></span></p>
|
|||
|
<p><code>REGION_ACTIVE</code> (integer)</p>
|
|||
|
<p>Indicates if the region is currently active. It can be assigned 0 or 1
|
|||
|
to deactivate and activate the region respectively. A value of 2
|
|||
|
activates the region in line-wise mode with the highlighted text
|
|||
|
extending for whole lines only; see <a href="#Character-Highlighting">Character
|
|||
|
Highlighting</a>.</p>
|
|||
|
<p><span id="index-region_005fhighlight"></span></p>
|
|||
|
<p><code>region_highlight</code> (array)</p>
|
|||
|
<p>Each element of this array may be set to a string that describes
|
|||
|
highlighting for an arbitrary region of the command line that will take
|
|||
|
effect the next time the command line is redisplayed. Highlighting and
|
|||
|
<code>POSTDISPLAY</code> are possible, but note that the <code>P</code> flag is needed for
|
|||
|
character indexing to include <code>PREDISPLAY</code>.</p>
|
|||
|
<p>Each string consists of the following parts:</p>
|
|||
|
<ul>
|
|||
|
<li>Optionally, a ‘<code>P</code>’ to signify that the start and end offset that
|
|||
|
follow include any string set by the <code>PREDISPLAY</code> special parameter;
|
|||
|
this is needed if the predisplay string itself is to be highlighted.
|
|||
|
Whitespace may follow the ‘<code>P</code>’.</li>
|
|||
|
<li>A start offset in the same units as <code>CURSOR</code>, terminated by
|
|||
|
whitespace.</li>
|
|||
|
<li>An end offset in the same units as <code>CURSOR</code>, terminated by
|
|||
|
whitespace.</li>
|
|||
|
<li>A highlight specification in the same format as used for contexts in
|
|||
|
the parameter <code>zle_highlight</code>, see <a href="#Character-Highlighting">Character
|
|||
|
Highlighting</a>; for example, <code>standout</code> or
|
|||
|
<code>fg=red,bold</code>.</li>
|
|||
|
</ul>
|
|||
|
<p>For example,</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">region_highlight=("P0 20 bold")
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>specifies that the first twenty characters of the text including any
|
|||
|
predisplay string should be highlighted in bold.</p>
|
|||
|
<p>Note that the effect of <code>region_highlight</code> is not saved and disappears
|
|||
|
as soon as the line is accepted.</p>
|
|||
|
<p>The final highlighting on the command line depends on both
|
|||
|
<code>region_highlight</code> and <code>zle_highlight</code>; see <a href="#Character-Highlighting">Character
|
|||
|
Highlighting</a> for details.</p>
|
|||
|
<p><span id="index-registers"></span></p>
|
|||
|
<p><code>registers</code> (associative array)</p>
|
|||
|
<p>The contents of each of the vi register buffers. These are typically set
|
|||
|
using <code>vi-set-buffer</code> followed by a delete, change or yank command.</p>
|
|||
|
<p><span id="index-SUFFIX_005fACTIVE"></span>
|
|||
|
<span id="index-SUFFIX_005fSTART"></span>
|
|||
|
<span id="index-SUFFIX_005fEND"></span></p>
|
|||
|
<p><code>SUFFIX_ACTIVE</code> (integer)</p>
|
|||
|
<p><code>SUFFIX_START</code> (integer)</p>
|
|||
|
<p><code>SUFFIX_END</code> (integer)</p>
|
|||
|
<p><code>SUFFIX_ACTIVE</code> indicates whether an auto-removable completion suffix is
|
|||
|
currently active. <code>SUFFIX_START</code> and <code>SUFFIX_END</code> give the location of
|
|||
|
the suffix and are in the same units as <code>CURSOR</code>. They are only valid
|
|||
|
for reading when <code>SUFFIX_ACTIVE</code> is non-zero.</p>
|
|||
|
<p>All parameters are read-only.</p>
|
|||
|
<p><span id="index-UNDO_005fCHANGE_005fNO"></span></p>
|
|||
|
<p><code>UNDO_CHANGE_NO</code> (integer)</p>
|
|||
|
<p>A number representing the state of the undo history. The only use of
|
|||
|
this is passing as an argument to the <code>undo</code> widget in order to undo
|
|||
|
back to the recorded point. Read-only.</p>
|
|||
|
<p><span id="index-UNDO_005fLIMIT_005fNO"></span></p>
|
|||
|
<p><code>UNDO_LIMIT_NO</code> (integer)</p>
|
|||
|
<p>A number corresponding to an existing change in the undo history;
|
|||
|
compare <code>UNDO_CHANGE_NO</code>. If this is set to a value greater than zero,
|
|||
|
the <code>undo</code> command will not allow the line to be undone beyond the given
|
|||
|
change number. It is still possible to use ‘<code>zle undo</code> <code>change</code>’ in a
|
|||
|
widget to undo beyond that point; in that case, it will not be possible
|
|||
|
to undo at all until <code>UNDO_LIMIT_NO</code> is reduced. Set to 0 to disable the
|
|||
|
limit.</p>
|
|||
|
<p>A typical use of this variable in a widget function is as follows (note
|
|||
|
the additional function scope is required):</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">() {
|
|||
|
local UNDO_LIMIT_NO=$UNDO_CHANGE_NO
|
|||
|
# Perform some form of recursive edit.
|
|||
|
}
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p><span id="index-WIDGET"></span></p>
|
|||
|
<p><code>WIDGET</code> (scalar)</p>
|
|||
|
<p>The name of the widget currently being executed; read-only.</p>
|
|||
|
<p><span id="index-WIDGETFUNC"></span></p>
|
|||
|
<p><code>WIDGETFUNC</code> (scalar)</p>
|
|||
|
<p>The name of the shell function that implements a widget defined with
|
|||
|
either <code>zle -N</code> or <code>zle -C</code>. In the former case, this is the second
|
|||
|
argument to the <code>zle -N</code> command that defined the widget, or the first
|
|||
|
argument if there was no second argument. In the latter case this is the
|
|||
|
third argument to the <code>zle -C</code> command that defined the widget.
|
|||
|
Read-only.</p>
|
|||
|
<p><span id="index-WIDGETSTYLE"></span></p>
|
|||
|
<p><code>WIDGETSTYLE</code> (scalar)</p>
|
|||
|
<p>Describes the implementation behind the completion widget currently
|
|||
|
being executed; the second argument that followed <code>zle -C</code> when the
|
|||
|
widget was defined. This is the name of a builtin completion widget. For
|
|||
|
widgets defined with <code>zle -N</code> this is set to the empty string.
|
|||
|
Read-only.</p>
|
|||
|
<p><span id="index-YANK_005fACTIVE"></span>
|
|||
|
<span id="index-YANK_005fSTART"></span>
|
|||
|
<span id="index-YANK_005fEND"></span></p>
|
|||
|
<p><code>YANK_ACTIVE</code> (integer)</p>
|
|||
|
<p><code>YANK_START</code> (integer)</p>
|
|||
|
<p><code>YANK_END</code> (integer)</p>
|
|||
|
<p><code>YANK_ACTIVE</code> indicates whether text has just been yanked (pasted) into
|
|||
|
the buffer. <code>YANK_START</code> and <code>YANK_END</code> give the location of the pasted
|
|||
|
text and are in the same units as <code>CURSOR</code>. They are only valid for
|
|||
|
reading when <code>YANK_ACTIVE</code> is non-zero. They can also be assigned by
|
|||
|
widgets that insert text in a yank-like fashion, for example wrappers of
|
|||
|
<code>bracketed-paste</code>. See also <code>zle -f</code>.</p>
|
|||
|
<p><code>YANK_ACTIVE</code> is read-only.</p>
|
|||
|
<p><span id="index-ZLE_005fRECURSIVE"></span></p>
|
|||
|
<p><code>ZLE_RECURSIVE</code> (integer)</p>
|
|||
|
<p>Usually zero, but incremented inside any instance of <code>recursive-edit</code>.
|
|||
|
Hence indicates the current recursion level.</p>
|
|||
|
<p><code>ZLE_RECURSIVE</code> is read-only.</p>
|
|||
|
<p><span id="index-ZLE_005fSTATE"></span></p>
|
|||
|
<p><code>ZLE_STATE</code> (scalar)</p>
|
|||
|
<p>Contains a set of space-separated words that describe the current <code>zle</code>
|
|||
|
state.</p>
|
|||
|
<p>Currently, the states shown are the insert mode as set by the
|
|||
|
<code>overwrite-mode</code> or <code>vi-replace</code> widgets and whether history commands
|
|||
|
will visit imported entries as controlled by the set-local-history
|
|||
|
widget. The string contains ‘<code>insert</code>’ if characters to be inserted on
|
|||
|
the command line move existing characters to the right or ‘<code>overwrite</code>’
|
|||
|
if characters to be inserted overwrite existing characters. It contains
|
|||
|
‘<code>localhistory</code>’ if only local history commands will be visited or
|
|||
|
‘<code>globalhistory</code>’ if imported history commands will also be visited.</p>
|
|||
|
<p>The substrings are sorted in alphabetical order so that if you want to
|
|||
|
test for two specific substrings in a future-proof way, you can do match
|
|||
|
by doing:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">if [[ $ZLE_STATE == *globalhistory*insert* ]]; then ...; fi
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<hr />
|
|||
|
<p><span id="Special-Widgets"></span></p>
|
|||
|
<h3 id="1851-special-widgets"><a class="header" href="#1851-special-widgets">18.5.1 Special Widgets</a></h3>
|
|||
|
<p>There are a few user-defined widgets which are special to the shell. If
|
|||
|
they do not exist, no special action is taken. The environment provided
|
|||
|
is identical to that for any other editing widget.</p>
|
|||
|
<p><span id="index-zle_002disearch_002dexit"></span></p>
|
|||
|
<p><code>zle-isearch-exit</code></p>
|
|||
|
<p>Executed at the end of incremental search at the point where the isearch
|
|||
|
prompt is removed from the display. See <code>zle-isearch-update</code> for an
|
|||
|
example.</p>
|
|||
|
<p><span id="index-zle_002disearch_002dupdate"></span></p>
|
|||
|
<p><code>zle-isearch-update</code></p>
|
|||
|
<p>Executed within incremental search when the display is about to be
|
|||
|
redrawn. Additional output below the incremental search prompt can be
|
|||
|
generated by using ‘<code>zle -M</code>’ within the widget. For example,</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle-isearch-update() { zle -M "Line $HISTNO"; }
|
|||
|
zle -N zle-isearch-update
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>Note the line output by ‘<code>zle -M</code>’ is not deleted on exit from
|
|||
|
incremental search. This can be done from a <code>zle-isearch-exit</code> widget:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle-isearch-exit() { zle -M ""; }
|
|||
|
zle -N zle-isearch-exit
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p><span id="index-zle_002dline_002dpre_002dredraw"></span></p>
|
|||
|
<p><code>zle-line-pre-redraw</code></p>
|
|||
|
<p>Executed whenever the input line is about to be redrawn, providing an
|
|||
|
opportunity to update the region_highlight array.</p>
|
|||
|
<p><span id="index-zle_002dline_002dinit"></span></p>
|
|||
|
<p><code>zle-line-init</code></p>
|
|||
|
<p>Executed every time the line editor is started to read a new line of
|
|||
|
input. The following example puts the line editor into vi command mode
|
|||
|
when it starts up.</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle-line-init() { zle -K vicmd; }
|
|||
|
zle -N zle-line-init
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>(The command inside the function sets the keymap directly; it is
|
|||
|
equivalent to <code>zle vi-cmd-mode</code>.)</p>
|
|||
|
<p><span id="index-zle_002dline_002dfinish"></span></p>
|
|||
|
<p><code>zle-line-finish</code></p>
|
|||
|
<p>This is similar to <code>zle-line-init</code> but is executed every time the line
|
|||
|
editor has finished reading a line of input.</p>
|
|||
|
<p><span id="index-zle_002dhistory_002dline_002dset"></span></p>
|
|||
|
<p><code>zle-history-line-set</code></p>
|
|||
|
<p>Executed when the history line changes.</p>
|
|||
|
<p><span id="index-zle_002dkeymap_002dselect"></span></p>
|
|||
|
<p><code>zle-keymap-select</code></p>
|
|||
|
<p>Executed every time the keymap changes, i.e. the special parameter
|
|||
|
<code>KEYMAP</code> is set to a different value, while the line editor is active.
|
|||
|
Initialising the keymap when the line editor starts does not cause the
|
|||
|
widget to be called.</p>
|
|||
|
<p>The value <code>$KEYMAP</code> within the function reflects the new keymap. The old
|
|||
|
keymap is passed as the sole argument.</p>
|
|||
|
<p>This can be used for detecting switches between the vi command (<code>vicmd</code>)
|
|||
|
and insert (usually <code>main</code>) keymaps.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Standard-Widgets"></span></p>
|
|||
|
<h2 id="186-standard-widgets"><a class="header" href="#186-standard-widgets">18.6 Standard Widgets</a></h2>
|
|||
|
<p><span id="index-widgets_002c-standard"></span></p>
|
|||
|
<p>The following is a list of all the standard widgets, and their default
|
|||
|
bindings in emacs mode, vi command mode and vi insert mode (the
|
|||
|
‘<code>emacs</code>’, ‘<code>vicmd</code>’ and ‘<code>viins</code>’ keymaps, respectively).</p>
|
|||
|
<p>Note that cursor keys are bound to movement keys in all three keymaps;
|
|||
|
the shell assumes that the cursor keys send the key sequences reported
|
|||
|
by the terminal-handling library (termcap or terminfo). The key
|
|||
|
sequences shown in the list are those based on the VT100, common on many
|
|||
|
modern terminals, but in fact these are not necessarily bound. In the
|
|||
|
case of the <code>viins</code> keymap, the initial escape character of the
|
|||
|
sequences serves also to return to the <code>vicmd</code> keymap: whether this
|
|||
|
happens is determined by the <code>KEYTIMEOUT</code> parameter, see
|
|||
|
<a href="Parameters.html#Parameters">Parameters</a>.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Movement"></span> <span id="Movement-1"></span></p>
|
|||
|
<h3 id="1861-movement"><a class="header" href="#1861-movement">18.6.1 Movement</a></h3>
|
|||
|
<p><span id="index-vi_002dbackward_002dblank_002dword"></span></p>
|
|||
|
<p><code>vi-backward-blank-word</code> (unbound) (<code>B</code>) (unbound)</p>
|
|||
|
<p>Move backward one word, where a word is defined as a series of non-blank
|
|||
|
characters.</p>
|
|||
|
<p><span id="index-vi_002dbackward_002dblank_002dword_002dend"></span></p>
|
|||
|
<p><code>vi-backward-blank-word-end</code> (unbound) (<code>gE</code>) (unbound)</p>
|
|||
|
<p>Move to the end of the previous word, where a word is defined as a
|
|||
|
series of non-blank characters.</p>
|
|||
|
<p><span id="index-backward_002dchar"></span></p>
|
|||
|
<p><code>backward-char</code> (<code>^B ESC-[D</code>) (unbound) (unbound)</p>
|
|||
|
<p>Move backward one character.</p>
|
|||
|
<p><span id="index-vi_002dbackward_002dchar"></span></p>
|
|||
|
<p><code>vi-backward-char</code> (unbound) (<code>^H h ^?</code>) (<code>ESC-[D</code>)</p>
|
|||
|
<p>Move backward one character, without changing lines.</p>
|
|||
|
<p><span id="index-backward_002dword"></span></p>
|
|||
|
<p><code>backward-word</code> (<code>ESC-B ESC-b</code>) (unbound) (unbound)</p>
|
|||
|
<p>Move to the beginning of the previous word.</p>
|
|||
|
<p><span id="index-emacs_002dbackward_002dword"></span></p>
|
|||
|
<p><code>emacs-backward-word</code></p>
|
|||
|
<p>Move to the beginning of the previous word.</p>
|
|||
|
<p><span id="index-vi_002dbackward_002dword"></span></p>
|
|||
|
<p><code>vi-backward-word</code> (unbound) (<code>b</code>) (unbound)</p>
|
|||
|
<p>Move to the beginning of the previous word, vi-style.</p>
|
|||
|
<p><span id="index-vi_002dbackward_002dword_002dend"></span></p>
|
|||
|
<p><code>vi-backward-word-end</code> (unbound) (<code>ge</code>) (unbound)</p>
|
|||
|
<p>Move to the end of the previous word, vi-style.</p>
|
|||
|
<p><span id="index-beginning_002dof_002dline"></span></p>
|
|||
|
<p><code>beginning-of-line</code> (<code>^A</code>) (unbound) (unbound)</p>
|
|||
|
<p>Move to the beginning of the line. If already at the beginning of the
|
|||
|
line, move to the beginning of the previous line, if any.</p>
|
|||
|
<p><span id="index-vi_002dbeginning_002dof_002dline"></span></p>
|
|||
|
<p><code>vi-beginning-of-line</code></p>
|
|||
|
<p>Move to the beginning of the line, without changing lines.</p>
|
|||
|
<p><span id="index-down_002dline"></span></p>
|
|||
|
<p><code>down-line</code> (unbound) (unbound) (unbound)</p>
|
|||
|
<p>Move down a line in the buffer.</p>
|
|||
|
<p><span id="index-end_002dof_002dline"></span></p>
|
|||
|
<p><code>end-of-line</code> (<code>^E</code>) (unbound) (unbound)</p>
|
|||
|
<p>Move to the end of the line. If already at the end of the line, move to
|
|||
|
the end of the next line, if any.</p>
|
|||
|
<p><span id="index-vi_002dend_002dof_002dline"></span></p>
|
|||
|
<p><code>vi-end-of-line</code> (unbound) (<code>$</code>) (unbound)</p>
|
|||
|
<p>Move to the end of the line. If an argument is given to this command,
|
|||
|
the cursor will be moved to the end of the line (argument - 1) lines
|
|||
|
down.</p>
|
|||
|
<p><span id="index-vi_002dforward_002dblank_002dword"></span></p>
|
|||
|
<p><code>vi-forward-blank-word</code> (unbound) (<code>W</code>) (unbound)</p>
|
|||
|
<p>Move forward one word, where a word is defined as a series of non-blank
|
|||
|
characters.</p>
|
|||
|
<p><span id="index-vi_002dforward_002dblank_002dword_002dend"></span></p>
|
|||
|
<p><code>vi-forward-blank-word-end</code> (unbound) (<code>E</code>) (unbound)</p>
|
|||
|
<p>Move to the end of the current word, or, if at the end of the current
|
|||
|
word, to the end of the next word, where a word is defined as a series
|
|||
|
of non-blank characters.</p>
|
|||
|
<p><span id="index-forward_002dchar"></span></p>
|
|||
|
<p><code>forward-char</code> (<code>^F ESC-[C</code>) (unbound) (unbound)</p>
|
|||
|
<p>Move forward one character.</p>
|
|||
|
<p><span id="index-vi_002dforward_002dchar"></span></p>
|
|||
|
<p><code>vi-forward-char</code> (unbound) (<code>space l</code>) (<code>ESC-[C</code>)</p>
|
|||
|
<p>Move forward one character.</p>
|
|||
|
<p><span id="index-vi_002dfind_002dnext_002dchar"></span></p>
|
|||
|
<p><code>vi-find-next-char</code> (<code>^X^F</code>) (<code>f</code>) (unbound)</p>
|
|||
|
<p>Read a character from the keyboard, and move to the next occurrence of
|
|||
|
it in the line.</p>
|
|||
|
<p><span id="index-vi_002dfind_002dnext_002dchar_002dskip"></span></p>
|
|||
|
<p><code>vi-find-next-char-skip</code> (unbound) (<code>t</code>) (unbound)</p>
|
|||
|
<p>Read a character from the keyboard, and move to the position just before
|
|||
|
the next occurrence of it in the line.</p>
|
|||
|
<p><span id="index-vi_002dfind_002dprev_002dchar"></span></p>
|
|||
|
<p><code>vi-find-prev-char</code> (unbound) (<code>F</code>) (unbound)</p>
|
|||
|
<p>Read a character from the keyboard, and move to the previous occurrence
|
|||
|
of it in the line.</p>
|
|||
|
<p><span id="index-vi_002dfind_002dprev_002dchar_002dskip"></span></p>
|
|||
|
<p><code>vi-find-prev-char-skip</code> (unbound) (<code>T</code>) (unbound)</p>
|
|||
|
<p>Read a character from the keyboard, and move to the position just after
|
|||
|
the previous occurrence of it in the line.</p>
|
|||
|
<p><span id="index-vi_002dfirst_002dnon_002dblank"></span></p>
|
|||
|
<p><code>vi-first-non-blank</code> (unbound) (<code>^</code>) (unbound)</p>
|
|||
|
<p>Move to the first non-blank character in the line.</p>
|
|||
|
<p><span id="index-vi_002dforward_002dword"></span></p>
|
|||
|
<p><code>vi-forward-word</code> (unbound) (<code>w</code>) (unbound)</p>
|
|||
|
<p>Move forward one word, vi-style.</p>
|
|||
|
<p><span id="index-forward_002dword"></span></p>
|
|||
|
<p><code>forward-word</code> (<code>ESC-F ESC-f</code>) (unbound) (unbound)</p>
|
|||
|
<p>Move to the beginning of the next word. The editor’s idea of a word is
|
|||
|
specified with the <code>WORDCHARS</code> parameter.</p>
|
|||
|
<p><span id="index-emacs_002dforward_002dword"></span></p>
|
|||
|
<p><code>emacs-forward-word</code></p>
|
|||
|
<p>Move to the end of the next word.</p>
|
|||
|
<p><span id="index-vi_002dforward_002dword_002dend"></span></p>
|
|||
|
<p><code>vi-forward-word-end</code> (unbound) (<code>e</code>) (unbound)</p>
|
|||
|
<p>Move to the end of the next word.</p>
|
|||
|
<p><span id="index-vi_002dgoto_002dcolumn"></span></p>
|
|||
|
<p><code>vi-goto-column</code> (<code>ESC-|</code>) (<code>|</code>) (unbound)</p>
|
|||
|
<p>Move to the column specified by the numeric argument.</p>
|
|||
|
<p><span id="index-vi_002dgoto_002dmark"></span></p>
|
|||
|
<p><code>vi-goto-mark</code> (unbound) (<code>‘</code>) (unbound)</p>
|
|||
|
<p>Move to the specified mark.</p>
|
|||
|
<p><span id="index-vi_002dgoto_002dmark_002dline"></span></p>
|
|||
|
<p><code>vi-goto-mark-line</code> (unbound) (<code>’</code>) (unbound)</p>
|
|||
|
<p>Move to beginning of the line containing the specified mark.</p>
|
|||
|
<p><span id="index-vi_002drepeat_002dfind"></span></p>
|
|||
|
<p><code>vi-repeat-find</code> (unbound) (<code>;</code>) (unbound)</p>
|
|||
|
<p>Repeat the last <code>vi-find</code> command.</p>
|
|||
|
<p><span id="index-vi_002drev_002drepeat_002dfind"></span></p>
|
|||
|
<p><code>vi-rev-repeat-find</code> (unbound) (<code>,</code>) (unbound)</p>
|
|||
|
<p>Repeat the last <code>vi-find</code> command in the opposite direction.</p>
|
|||
|
<p><span id="index-up_002dline"></span></p>
|
|||
|
<p><code>up-line</code> (unbound) (unbound) (unbound)</p>
|
|||
|
<p>Move up a line in the buffer.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="History-Control"></span> <span id="History-Control-1"></span></p>
|
|||
|
<h3 id="1862-history-control"><a class="header" href="#1862-history-control">18.6.2 History Control</a></h3>
|
|||
|
<p><span id="index-beginning_002dof_002dbuffer_002dor_002dhistory"></span></p>
|
|||
|
<p><code>beginning-of-buffer-or-history</code> (<code>ESC-<</code>) (<code>gg</code>) (unbound)</p>
|
|||
|
<p>Move to the beginning of the buffer, or if already there, move to the
|
|||
|
first event in the history list.</p>
|
|||
|
<p><span id="index-beginning_002dof_002dline_002dhist"></span></p>
|
|||
|
<p><code>beginning-of-line-hist</code></p>
|
|||
|
<p>Move to the beginning of the line. If already at the beginning of the
|
|||
|
buffer, move to the previous history line.</p>
|
|||
|
<p><span id="index-beginning_002dof_002dhistory"></span></p>
|
|||
|
<p><code>beginning-of-history</code></p>
|
|||
|
<p>Move to the first event in the history list.</p>
|
|||
|
<p><span id="index-down_002dline_002dor_002dhistory"></span></p>
|
|||
|
<p><code>down-line-or-history</code> (<code>^N ESC-[B</code>) (<code>j</code>) (<code>ESC-[B</code>)</p>
|
|||
|
<p>Move down a line in the buffer, or if already at the bottom line, move
|
|||
|
to the next event in the history list.</p>
|
|||
|
<p><span id="index-vi_002ddown_002dline_002dor_002dhistory"></span></p>
|
|||
|
<p><code>vi-down-line-or-history</code> (unbound) (<code>+</code>) (unbound)</p>
|
|||
|
<p>Move down a line in the buffer, or if already at the bottom line, move
|
|||
|
to the next event in the history list. Then move to the first non-blank
|
|||
|
character on the line.</p>
|
|||
|
<p><span id="index-down_002dline_002dor_002dsearch"></span></p>
|
|||
|
<p><code>down-line-or-search</code></p>
|
|||
|
<p>Move down a line in the buffer, or if already at the bottom line, search
|
|||
|
forward in the history for a line beginning with the first word in the
|
|||
|
buffer.</p>
|
|||
|
<p>If called from a function by the <code>zle</code> command with arguments, the first
|
|||
|
argument is taken as the string for which to search, rather than the
|
|||
|
first word in the buffer.</p>
|
|||
|
<p><span id="index-down_002dhistory"></span></p>
|
|||
|
<p><code>down-history</code> (unbound) (<code>^N</code>) (unbound)</p>
|
|||
|
<p>Move to the next event in the history list.</p>
|
|||
|
<p><span id="index-history_002dbeginning_002dsearch_002dbackward"></span></p>
|
|||
|
<p><code>history-beginning-search-backward</code></p>
|
|||
|
<p>Search backward in the history for a line beginning with the current
|
|||
|
line up to the cursor. This leaves the cursor in its original position.</p>
|
|||
|
<p><span id="index-end_002dof_002dbuffer_002dor_002dhistory"></span></p>
|
|||
|
<p><code>end-of-buffer-or-history</code> (<code>ESC-></code>) (unbound) (unbound)</p>
|
|||
|
<p>Move to the end of the buffer, or if already there, move to the last
|
|||
|
event in the history list.</p>
|
|||
|
<p><span id="index-end_002dof_002dline_002dhist"></span></p>
|
|||
|
<p><code>end-of-line-hist</code></p>
|
|||
|
<p>Move to the end of the line. If already at the end of the buffer, move
|
|||
|
to the next history line.</p>
|
|||
|
<p><span id="index-end_002dof_002dhistory"></span></p>
|
|||
|
<p><code>end-of-history</code></p>
|
|||
|
<p>Move to the last event in the history list.</p>
|
|||
|
<p><span id="index-vi_002dfetch_002dhistory"></span></p>
|
|||
|
<p><code>vi-fetch-history</code> (unbound) (<code>G</code>) (unbound)</p>
|
|||
|
<p>Fetch the history line specified by the numeric argument. This defaults
|
|||
|
to the current history line (i.e. the one that isn’t history yet).</p>
|
|||
|
<p><span id="index-history_002dincremental_002dsearch_002dbackward"></span></p>
|
|||
|
<p><code>history-incremental-search-backward</code> (<code>^R ^Xr</code>) (unbound) (unbound)</p>
|
|||
|
<p>Search backward incrementally for a specified string. The search is
|
|||
|
case-insensitive if the search string does not have uppercase letters
|
|||
|
and no numeric argument was given. The string may begin with ‘<code>^</code>’ to
|
|||
|
anchor the search to the beginning of the line. When called from a
|
|||
|
user-defined function returns the following statuses: 0, if the search
|
|||
|
succeeded; 1, if the search failed; 2, if the search term was a bad
|
|||
|
pattern; 3, if the search was aborted by the <code>send-break</code> command.</p>
|
|||
|
<p>A restricted set of editing functions is available in the mini-buffer.
|
|||
|
Keys are looked up in the special <code>isearch</code> keymap, and if not found
|
|||
|
there in the main keymap (note that by default the <code>isearch</code> keymap is
|
|||
|
empty). An interrupt signal, as defined by the stty setting, will stop
|
|||
|
the search and go back to the original line. An undefined key will have
|
|||
|
the same effect. Note that the following always perform the same task
|
|||
|
within incremental searches and cannot be replaced by user defined
|
|||
|
widgets, nor can the set of functions be extended. The supported
|
|||
|
functions are:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>accept-and-hold</code><br />
|
|||
|
<code>accept-and-infer-next-history</code><br />
|
|||
|
<code>accept-line</code><br />
|
|||
|
<code>accept-line-and-down-history</code><br />
|
|||
|
Perform the usual function after exiting incremental search. The
|
|||
|
command line displayed is executed.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>backward-delete-char</code><br />
|
|||
|
<code>vi-backward-delete-char</code><br />
|
|||
|
Back up one place in the search history. If the search has been
|
|||
|
repeated this does not immediately erase a character in the
|
|||
|
minibuffer.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>accept-search</code><br />
|
|||
|
Exit incremental search, retaining the command line but performing
|
|||
|
no further action. Note that this function is not bound by default
|
|||
|
and has no effect outside incremental search.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>backward-delete-word</code><br />
|
|||
|
<code>backward-kill-word</code><br />
|
|||
|
<code>vi-backward-kill-word</code><br />
|
|||
|
Back up one character in the minibuffer; if multiple searches have
|
|||
|
been performed since the character was inserted the search history
|
|||
|
is rewound to the point just before the character was entered. Hence
|
|||
|
this has the effect of repeating <code>backward-delete-char</code>.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>clear-screen</code><br />
|
|||
|
Clear the screen, remaining in incremental search mode.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>history-incremental-search-backward</code><br />
|
|||
|
Find the next occurrence of the contents of the mini-buffer. If the
|
|||
|
mini-buffer is empty, the most recent previously used search string
|
|||
|
is reinstated.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>history-incremental-search-forward</code><br />
|
|||
|
Invert the sense of the search.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>magic-space</code><br />
|
|||
|
Inserts a non-magical space.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>quoted-insert</code><br />
|
|||
|
<code>vi-quoted-insert</code><br />
|
|||
|
Quote the character to insert into the minibuffer.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>redisplay</code><br />
|
|||
|
Redisplay the command line, remaining in incremental search mode.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>vi-cmd-mode</code><br />
|
|||
|
Select the ‘<code>vicmd</code>’ keymap; the ‘<code>main</code>’ keymap (insert mode) will
|
|||
|
be selected initially.</p>
|
|||
|
<p>In addition, the modifications that were made while in vi insert
|
|||
|
mode are merged to form a single undo event.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>vi-repeat-search</code><br />
|
|||
|
<code>vi-rev-repeat-search</code><br />
|
|||
|
Repeat the search. The direction of the search is indicated in the
|
|||
|
mini-buffer.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>Any character that is not bound to one of the above functions, or
|
|||
|
<code>self-insert</code> or <code>self-insert-unmeta</code>, will cause the mode to be exited.
|
|||
|
The character is then looked up and executed in the keymap in effect at
|
|||
|
that point.</p>
|
|||
|
<p>When called from a widget function by the <code>zle</code> command, the incremental
|
|||
|
search commands can take a string argument. This will be treated as a
|
|||
|
string of keys, as for arguments to the <code>bindkey</code> command, and used as
|
|||
|
initial input for the command. Any characters in the string which are
|
|||
|
unused by the incremental search will be silently ignored. For example,</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle history-incremental-search-backward forceps
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>will search backwards for <code>forceps</code>, leaving the minibuffer containing
|
|||
|
the string ‘<code>forceps</code>’.</p>
|
|||
|
<p><span id="index-history_002dincremental_002dsearch_002dforward"></span></p>
|
|||
|
<p><code>history-incremental-search-forward</code> (<code>^S ^Xs</code>) (unbound) (unbound)</p>
|
|||
|
<p>Search forward incrementally for a specified string. The search is
|
|||
|
case-insensitive if the search string does not have uppercase letters
|
|||
|
and no numeric argument was given. The string may begin with ‘<code>^</code>’ to
|
|||
|
anchor the search to the beginning of the line. The functions available
|
|||
|
in the mini-buffer are the same as for
|
|||
|
<code>history-incremental-search-backward</code>.</p>
|
|||
|
<p><span id="index-history_002dincremental_002dpattern_002dsearch_002dbackward"></span>
|
|||
|
<span id="index-history_002dincremental_002dpattern_002dsearch_002dforward"></span></p>
|
|||
|
<p><code>history-incremental-pattern-search-backward</code></p>
|
|||
|
<p><code>history-incremental-pattern-search-forward</code></p>
|
|||
|
<p>These widgets behave similarly to the corresponding widgets with no
|
|||
|
<code>-pattern</code>, but the search string typed by the user is treated as a
|
|||
|
pattern, respecting the current settings of the various options
|
|||
|
affecting pattern matching. See <a href="Expansion.html#Filename-Generation">Filename
|
|||
|
Generation</a> for a description of
|
|||
|
patterns. If no numeric argument was given lowercase letters in the
|
|||
|
search string may match uppercase letters in the history. The string may
|
|||
|
begin with ‘<code>^</code>’ to anchor the search to the beginning of the line.</p>
|
|||
|
<p>The prompt changes to indicate an invalid pattern; this may simply
|
|||
|
indicate the pattern is not yet complete.</p>
|
|||
|
<p>Note that only non-overlapping matches are reported, so an expression
|
|||
|
with wildcards may return fewer matches on a line than are visible by
|
|||
|
inspection.</p>
|
|||
|
<p><span id="index-history_002dsearch_002dbackward"></span></p>
|
|||
|
<p><code>history-search-backward</code> (<code>ESC-P ESC-p</code>) (unbound) (unbound)</p>
|
|||
|
<p>Search backward in the history for a line beginning with the first word
|
|||
|
in the buffer.</p>
|
|||
|
<p>If called from a function by the <code>zle</code> command with arguments, the first
|
|||
|
argument is taken as the string for which to search, rather than the
|
|||
|
first word in the buffer.</p>
|
|||
|
<p><span id="index-vi_002dhistory_002dsearch_002dbackward"></span></p>
|
|||
|
<p><code>vi-history-search-backward</code> (unbound) (<code>/</code>) (unbound)</p>
|
|||
|
<p>Search backward in the history for a specified string. The string may
|
|||
|
begin with ‘<code>^</code>’ to anchor the search to the beginning of the line.</p>
|
|||
|
<p>A restricted set of editing functions is available in the mini-buffer.
|
|||
|
An interrupt signal, as defined by the stty setting, will stop the
|
|||
|
search. The functions available in the mini-buffer are: <code>accept-line</code>,
|
|||
|
<code>backward-delete-char</code>, <code>vi-backward-delete-char</code>, <code>backward-kill-word</code>,
|
|||
|
<code>vi-backward-kill-word</code>, <code>clear-screen</code>, <code>redisplay</code>, <code>quoted-insert</code>
|
|||
|
and <code>vi-quoted-insert</code>.</p>
|
|||
|
<p><code>vi-cmd-mode</code> is treated the same as accept-line, and <code>magic-space</code> is
|
|||
|
treated as a space. Any other character that is not bound to self-insert
|
|||
|
or self-insert-unmeta will beep and be ignored. If the function is
|
|||
|
called from vi command mode, the bindings of the current insert mode
|
|||
|
will be used.</p>
|
|||
|
<p>If called from a function by the <code>zle</code> command with arguments, the first
|
|||
|
argument is taken as the string for which to search, rather than the
|
|||
|
first word in the buffer.</p>
|
|||
|
<p><span id="index-history_002dsearch_002dforward"></span></p>
|
|||
|
<p><code>history-search-forward</code> (<code>ESC-N ESC-n</code>) (unbound) (unbound)</p>
|
|||
|
<p>Search forward in the history for a line beginning with the first word
|
|||
|
in the buffer.</p>
|
|||
|
<p>If called from a function by the <code>zle</code> command with arguments, the first
|
|||
|
argument is taken as the string for which to search, rather than the
|
|||
|
first word in the buffer.</p>
|
|||
|
<p><span id="index-vi_002dhistory_002dsearch_002dforward"></span></p>
|
|||
|
<p><code>vi-history-search-forward</code> (unbound) (<code>?</code>) (unbound)</p>
|
|||
|
<p>Search forward in the history for a specified string. The string may
|
|||
|
begin with ‘<code>^</code>’ to anchor the search to the beginning of the line. The
|
|||
|
functions available in the mini-buffer are the same as for
|
|||
|
<code>vi-history-search-backward</code>. Argument handling is also the same as for
|
|||
|
that command.</p>
|
|||
|
<p><span id="index-infer_002dnext_002dhistory"></span></p>
|
|||
|
<p><code>infer-next-history</code> (<code>^X^N</code>) (unbound) (unbound)</p>
|
|||
|
<p>Search in the history list for a line matching the current one and fetch
|
|||
|
the event following it.</p>
|
|||
|
<p><span id="index-insert_002dlast_002dword"></span></p>
|
|||
|
<p><code>insert-last-word</code> (<code>ESC-_ ESC-.</code>) (unbound) (unbound)</p>
|
|||
|
<p>Insert the last word from the previous history event at the cursor
|
|||
|
position. If a positive numeric argument is given, insert that word from
|
|||
|
the end of the previous history event. If the argument is zero or
|
|||
|
negative insert that word from the left (zero inserts the previous
|
|||
|
command word). Repeating this command replaces the word just inserted
|
|||
|
with the last word from the history event prior to the one just used;
|
|||
|
numeric arguments can be used in the same way to pick a word from that
|
|||
|
event.</p>
|
|||
|
<p>When called from a shell function invoked from a user-defined widget,
|
|||
|
the command can take one to three arguments. The first argument
|
|||
|
specifies a history offset which applies to successive calls to this
|
|||
|
widget: if it is -1, the default behaviour is used, while if it is 1,
|
|||
|
successive calls will move forwards through the history. The value 0 can
|
|||
|
be used to indicate that the history line examined by the previous
|
|||
|
execution of the command will be reexamined. Note that negative numbers
|
|||
|
should be preceded by a ‘<code>-``-</code>’ argument to avoid confusing them with
|
|||
|
options.</p>
|
|||
|
<p>If two arguments are given, the second specifies the word on the command
|
|||
|
line in normal array index notation (as a more natural alternative to
|
|||
|
the numeric argument). Hence 1 is the first word, and -1 (the default)
|
|||
|
is the last word.</p>
|
|||
|
<p>If a third argument is given, its value is ignored, but it is used to
|
|||
|
signify that the history offset is relative to the current history line,
|
|||
|
rather than the one remembered after the previous invocations of
|
|||
|
<code>insert-last-word</code>.</p>
|
|||
|
<p>For example, the default behaviour of the command corresponds to</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle insert-last-word -- -1 -1
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>while the command</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle insert-last-word -- -1 1 -
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>always copies the first word of the line in the history immediately
|
|||
|
before the line being edited. This has the side effect that later
|
|||
|
invocations of the widget will be relative to that line.</p>
|
|||
|
<p><span id="index-vi_002drepeat_002dsearch"></span></p>
|
|||
|
<p><code>vi-repeat-search</code> (unbound) (<code>n</code>) (unbound)</p>
|
|||
|
<p>Repeat the last vi history search.</p>
|
|||
|
<p><span id="index-vi_002drev_002drepeat_002dsearch"></span></p>
|
|||
|
<p><code>vi-rev-repeat-search</code> (unbound) (<code>N</code>) (unbound)</p>
|
|||
|
<p>Repeat the last vi history search, but in reverse.</p>
|
|||
|
<p><span id="index-up_002dline_002dor_002dhistory"></span></p>
|
|||
|
<p><code>up-line-or-history</code> (<code>^P ESC-[A</code>) (<code>k</code>) (<code>ESC-[A</code>)</p>
|
|||
|
<p>Move up a line in the buffer, or if already at the top line, move to the
|
|||
|
previous event in the history list.</p>
|
|||
|
<p><span id="index-vi_002dup_002dline_002dor_002dhistory"></span></p>
|
|||
|
<p><code>vi-up-line-or-history</code> (unbound) (<code>-</code>) (unbound)</p>
|
|||
|
<p>Move up a line in the buffer, or if already at the top line, move to the
|
|||
|
previous event in the history list. Then move to the first non-blank
|
|||
|
character on the line.</p>
|
|||
|
<p><span id="index-up_002dline_002dor_002dsearch"></span></p>
|
|||
|
<p><code>up-line-or-search</code></p>
|
|||
|
<p>Move up a line in the buffer, or if already at the top line, search
|
|||
|
backward in the history for a line beginning with the first word in the
|
|||
|
buffer.</p>
|
|||
|
<p>If called from a function by the <code>zle</code> command with arguments, the first
|
|||
|
argument is taken as the string for which to search, rather than the
|
|||
|
first word in the buffer.</p>
|
|||
|
<p><span id="index-up_002dhistory"></span></p>
|
|||
|
<p><code>up-history</code> (unbound) (<code>^P</code>) (unbound)</p>
|
|||
|
<p>Move to the previous event in the history list.</p>
|
|||
|
<p><span id="index-history_002dbeginning_002dsearch_002dforward"></span></p>
|
|||
|
<p><code>history-beginning-search-forward</code></p>
|
|||
|
<p>Search forward in the history for a line beginning with the current line
|
|||
|
up to the cursor. This leaves the cursor in its original position.</p>
|
|||
|
<p><span id="index-set_002dlocal_002dhistory"></span></p>
|
|||
|
<p><code>set-local-history</code></p>
|
|||
|
<p>By default, history movement commands visit the imported lines as well
|
|||
|
as the local lines. This widget lets you toggle this on and off, or set
|
|||
|
it with the numeric argument. Zero for both local and imported lines and
|
|||
|
nonzero for only local lines.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Modifying-Text"></span> <span id="Modifying-Text-1"></span></p>
|
|||
|
<h3 id="1863-modifying-text"><a class="header" href="#1863-modifying-text">18.6.3 Modifying Text</a></h3>
|
|||
|
<p><span id="index-vi_002dadd_002deol"></span></p>
|
|||
|
<p><code>vi-add-eol</code> (unbound) (<code>A</code>) (unbound)</p>
|
|||
|
<p>Move to the end of the line and enter insert mode.</p>
|
|||
|
<p><span id="index-vi_002dadd_002dnext"></span></p>
|
|||
|
<p><code>vi-add-next</code> (unbound) (<code>a</code>) (unbound)</p>
|
|||
|
<p>Enter insert mode after the current cursor position, without changing
|
|||
|
lines.</p>
|
|||
|
<p><span id="index-backward_002ddelete_002dchar"></span></p>
|
|||
|
<p><code>backward-delete-char</code> (<code>^H ^?</code>) (unbound) (unbound)</p>
|
|||
|
<p>Delete the character behind the cursor.</p>
|
|||
|
<p><span id="index-vi_002dbackward_002ddelete_002dchar"></span></p>
|
|||
|
<p><code>vi-backward-delete-char</code> (unbound) (<code>X</code>) (<code>^H</code>)</p>
|
|||
|
<p>Delete the character behind the cursor, without changing lines. If in
|
|||
|
insert mode, this won’t delete past the point where insert mode was last
|
|||
|
entered.</p>
|
|||
|
<p><span id="index-backward_002ddelete_002dword"></span></p>
|
|||
|
<p><code>backward-delete-word</code></p>
|
|||
|
<p>Delete the word behind the cursor.</p>
|
|||
|
<p><span id="index-backward_002dkill_002dline"></span></p>
|
|||
|
<p><code>backward-kill-line</code></p>
|
|||
|
<p>Kill from the beginning of the line to the cursor position.</p>
|
|||
|
<p><span id="index-backward_002dkill_002dword"></span></p>
|
|||
|
<p><code>backward-kill-word</code> (<code>^W ESC-^H ESC-^?</code>) (unbound) (unbound)</p>
|
|||
|
<p>Kill the word behind the cursor.</p>
|
|||
|
<p><span id="index-vi_002dbackward_002dkill_002dword"></span></p>
|
|||
|
<p><code>vi-backward-kill-word</code> (unbound) (unbound) (<code>^W</code>)</p>
|
|||
|
<p>Kill the word behind the cursor, without going past the point where
|
|||
|
insert mode was last entered.</p>
|
|||
|
<p><span id="index-capitalize_002dword"></span></p>
|
|||
|
<p><code>capitalize-word</code> (<code>ESC-C ESC-c</code>) (unbound) (unbound)</p>
|
|||
|
<p>Capitalize the current word and move past it.</p>
|
|||
|
<p><span id="index-vi_002dchange"></span></p>
|
|||
|
<p><code>vi-change</code> (unbound) (<code>c</code>) (unbound)</p>
|
|||
|
<p>Read a movement command from the keyboard, and kill from the cursor
|
|||
|
position to the endpoint of the movement. Then enter insert mode. If the
|
|||
|
command is <code>vi-change</code>, change the current line.</p>
|
|||
|
<p>For compatibility with vi, if the command is <code>vi-forward-word</code> or
|
|||
|
<code>vi-forward-blank-word</code>, the whitespace after the word is not included.
|
|||
|
If you prefer the more consistent behaviour with the whitespace included
|
|||
|
use the following key binding:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">bindkey -a -s cw dwi
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p><span id="index-vi_002dchange_002deol"></span></p>
|
|||
|
<p><code>vi-change-eol</code> (unbound) (<code>C</code>) (unbound)</p>
|
|||
|
<p>Kill to the end of the line and enter insert mode.</p>
|
|||
|
<p><span id="index-vi_002dchange_002dwhole_002dline"></span></p>
|
|||
|
<p><code>vi-change-whole-line</code> (unbound) (<code>S</code>) (unbound)</p>
|
|||
|
<p>Kill the current line and enter insert mode.</p>
|
|||
|
<p><span id="index-copy_002dregion_002das_002dkill"></span></p>
|
|||
|
<p><code>copy-region-as-kill</code> (<code>ESC-W ESC-w</code>) (unbound) (unbound)</p>
|
|||
|
<p>Copy the area from the cursor to the mark to the kill buffer.</p>
|
|||
|
<p>If called from a ZLE widget function in the form ‘<code>zle copy-region-as-kill</code> <code>string</code>’ then <code>string</code> will be taken as the text
|
|||
|
to copy to the kill buffer. The cursor, the mark and the text on the
|
|||
|
command line are not used in this case.</p>
|
|||
|
<p><span id="index-copy_002dprev_002dword"></span></p>
|
|||
|
<p><code>copy-prev-word</code> (<code>ESC-^_</code>) (unbound) (unbound)</p>
|
|||
|
<p>Duplicate the word to the left of the cursor.</p>
|
|||
|
<p><span id="index-copy_002dprev_002dshell_002dword"></span></p>
|
|||
|
<p><code>copy-prev-shell-word</code></p>
|
|||
|
<p>Like <code>copy-prev-word</code>, but the word is found by using shell parsing,
|
|||
|
whereas <code>copy-prev-word</code> looks for blanks. This makes a difference when
|
|||
|
the word is quoted and contains spaces.</p>
|
|||
|
<p><span id="index-vi_002ddelete"></span></p>
|
|||
|
<p><code>vi-delete</code> (unbound) (<code>d</code>) (unbound)</p>
|
|||
|
<p>Read a movement command from the keyboard, and kill from the cursor
|
|||
|
position to the endpoint of the movement. If the command is <code>vi-delete</code>,
|
|||
|
kill the current line.</p>
|
|||
|
<p><span id="index-delete_002dchar"></span></p>
|
|||
|
<p><code>delete-char</code></p>
|
|||
|
<p>Delete the character under the cursor.</p>
|
|||
|
<p><span id="index-vi_002ddelete_002dchar"></span></p>
|
|||
|
<p><code>vi-delete-char</code> (unbound) (<code>x</code>) (unbound)</p>
|
|||
|
<p>Delete the character under the cursor, without going past the end of the
|
|||
|
line.</p>
|
|||
|
<p><span id="index-delete_002dword"></span></p>
|
|||
|
<p><code>delete-word</code></p>
|
|||
|
<p>Delete the current word.</p>
|
|||
|
<p><span id="index-down_002dcase_002dword"></span></p>
|
|||
|
<p><code>down-case-word</code> (<code>ESC-L ESC-l</code>) (unbound) (unbound)</p>
|
|||
|
<p>Convert the current word to all lowercase and move past it.</p>
|
|||
|
<p><span id="index-vi_002ddown_002dcase"></span></p>
|
|||
|
<p><code>vi-down-case</code> (unbound) (<code>gu</code>) (unbound)</p>
|
|||
|
<p>Read a movement command from the keyboard, and convert all characters
|
|||
|
from the cursor position to the endpoint of the movement to lowercase.
|
|||
|
If the movement command is <code>vi-down-case</code>, swap the case of all
|
|||
|
characters on the current line.</p>
|
|||
|
<p><span id="index-kill_002dword"></span></p>
|
|||
|
<p><code>kill-word</code> (<code>ESC-D ESC-d</code>) (unbound) (unbound)</p>
|
|||
|
<p>Kill the current word.</p>
|
|||
|
<p><span id="index-gosmacs_002dtranspose_002dchars"></span></p>
|
|||
|
<p><code>gosmacs-transpose-chars</code></p>
|
|||
|
<p>Exchange the two characters behind the cursor.</p>
|
|||
|
<p><span id="index-vi_002dindent"></span></p>
|
|||
|
<p><code>vi-indent</code> (unbound) (<code>></code>) (unbound)</p>
|
|||
|
<p>Indent a number of lines.</p>
|
|||
|
<p><span id="index-vi_002dinsert"></span></p>
|
|||
|
<p><code>vi-insert</code> (unbound) (<code>i</code>) (unbound)</p>
|
|||
|
<p>Enter insert mode.</p>
|
|||
|
<p><span id="index-vi_002dinsert_002dbol"></span></p>
|
|||
|
<p><code>vi-insert-bol</code> (unbound) (<code>I</code>) (unbound)</p>
|
|||
|
<p>Move to the first non-blank character on the line and enter insert mode.</p>
|
|||
|
<p><span id="index-vi_002djoin"></span></p>
|
|||
|
<p><code>vi-join</code> (<code>^X^J</code>) (<code>J</code>) (unbound)</p>
|
|||
|
<p>Join the current line with the next one.</p>
|
|||
|
<p><span id="index-kill_002dline"></span></p>
|
|||
|
<p><code>kill-line</code> (<code>^K</code>) (unbound) (unbound)</p>
|
|||
|
<p>Kill from the cursor to the end of the line. If already on the end of
|
|||
|
the line, kill the newline character.</p>
|
|||
|
<p><span id="index-vi_002dkill_002dline"></span></p>
|
|||
|
<p><code>vi-kill-line</code> (unbound) (unbound) (<code>^U</code>)</p>
|
|||
|
<p>Kill from the cursor back to wherever insert mode was last entered.</p>
|
|||
|
<p><span id="index-vi_002dkill_002deol"></span></p>
|
|||
|
<p><code>vi-kill-eol</code> (unbound) (<code>D</code>) (unbound)</p>
|
|||
|
<p>Kill from the cursor to the end of the line.</p>
|
|||
|
<p><span id="index-kill_002dregion"></span></p>
|
|||
|
<p><code>kill-region</code></p>
|
|||
|
<p>Kill from the cursor to the mark.</p>
|
|||
|
<p><span id="index-kill_002dbuffer"></span></p>
|
|||
|
<p><code>kill-buffer</code> (<code>^X^K</code>) (unbound) (unbound)</p>
|
|||
|
<p>Kill the entire buffer.</p>
|
|||
|
<p><span id="index-kill_002dwhole_002dline"></span></p>
|
|||
|
<p><code>kill-whole-line</code> (<code>^U</code>) (unbound) (unbound)</p>
|
|||
|
<p>Kill the current line.</p>
|
|||
|
<p><span id="index-vi_002dmatch_002dbracket"></span></p>
|
|||
|
<p><code>vi-match-bracket</code> (<code>^X^B</code>) (<code>%</code>) (unbound)</p>
|
|||
|
<p>Move to the bracket character (one of <code>{}</code>, <code>()</code> or <code>[]</code>) that matches
|
|||
|
the one under the cursor. If the cursor is not on a bracket character,
|
|||
|
move forward without going past the end of the line to find one, and
|
|||
|
then go to the matching bracket.</p>
|
|||
|
<p><span id="index-vi_002dopen_002dline_002dabove"></span></p>
|
|||
|
<p><code>vi-open-line-above</code> (unbound) (<code>O</code>) (unbound)</p>
|
|||
|
<p>Open a line above the cursor and enter insert mode.</p>
|
|||
|
<p><span id="index-vi_002dopen_002dline_002dbelow"></span></p>
|
|||
|
<p><code>vi-open-line-below</code> (unbound) (<code>o</code>) (unbound)</p>
|
|||
|
<p>Open a line below the cursor and enter insert mode.</p>
|
|||
|
<p><span id="index-vi_002doper_002dswap_002dcase"></span></p>
|
|||
|
<p><code>vi-oper-swap-case</code> (unbound) (<code>g~</code>) (unbound)</p>
|
|||
|
<p>Read a movement command from the keyboard, and swap the case of all
|
|||
|
characters from the cursor position to the endpoint of the movement. If
|
|||
|
the movement command is <code>vi-oper-swap-case</code>, swap the case of all
|
|||
|
characters on the current line.</p>
|
|||
|
<p><span id="index-overwrite_002dmode"></span></p>
|
|||
|
<p><code>overwrite-mode</code> (<code>^X^O</code>) (unbound) (unbound)</p>
|
|||
|
<p>Toggle between overwrite mode and insert mode.</p>
|
|||
|
<p><span id="index-vi_002dput_002dbefore"></span></p>
|
|||
|
<p><code>vi-put-before</code> (unbound) (<code>P</code>) (unbound)</p>
|
|||
|
<p>Insert the contents of the kill buffer before the cursor. If the kill
|
|||
|
buffer contains a sequence of lines (as opposed to characters), paste it
|
|||
|
above the current line.</p>
|
|||
|
<p><span id="index-vi_002dput_002dafter"></span></p>
|
|||
|
<p><code>vi-put-after</code> (unbound) (<code>p</code>) (unbound)</p>
|
|||
|
<p>Insert the contents of the kill buffer after the cursor. If the kill
|
|||
|
buffer contains a sequence of lines (as opposed to characters), paste it
|
|||
|
below the current line.</p>
|
|||
|
<p><span id="index-put_002dreplace_002dselection"></span></p>
|
|||
|
<p><code>put-replace-selection</code> (unbound) (unbound) (unbound)</p>
|
|||
|
<p>Replace the contents of the current region or selection with the
|
|||
|
contents of the kill buffer. If the kill buffer contains a sequence of
|
|||
|
lines (as opposed to characters), the current line will be split by the
|
|||
|
pasted lines.</p>
|
|||
|
<p><span id="index-quoted_002dinsert"></span></p>
|
|||
|
<p><code>quoted-insert</code> (<code>^V</code>) (unbound) (unbound)</p>
|
|||
|
<p>Insert the next character typed into the buffer literally. An interrupt
|
|||
|
character will not be inserted.</p>
|
|||
|
<p><span id="index-vi_002dquoted_002dinsert"></span></p>
|
|||
|
<p><code>vi-quoted-insert</code> (unbound) (unbound) (<code>^Q ^V</code>)</p>
|
|||
|
<p>Display a ‘<code>^</code>’ at the cursor position, and insert the next character
|
|||
|
typed into the buffer literally. An interrupt character will not be
|
|||
|
inserted.</p>
|
|||
|
<p><span id="index-quote_002dline"></span></p>
|
|||
|
<p><code>quote-line</code> (<code>ESC-’</code>) (unbound) (unbound)</p>
|
|||
|
<p>Quote the current line; that is, put a ‘<code>’</code>’ character at the beginning
|
|||
|
and the end, and convert all ‘<code>’</code>’ characters to ‘<code>’\’’</code>’.</p>
|
|||
|
<p><span id="index-quote_002dregion"></span></p>
|
|||
|
<p><code>quote-region</code> (<code>ESC-"</code>) (unbound) (unbound)</p>
|
|||
|
<p>Quote the region from the cursor to the mark.</p>
|
|||
|
<p><span id="index-vi_002dreplace"></span></p>
|
|||
|
<p><code>vi-replace</code> (unbound) (<code>R</code>) (unbound)</p>
|
|||
|
<p>Enter overwrite mode.</p>
|
|||
|
<p><span id="index-vi_002drepeat_002dchange"></span></p>
|
|||
|
<p><code>vi-repeat-change</code> (unbound) (<code>.</code>) (unbound)</p>
|
|||
|
<p>Repeat the last vi mode text modification. If a count was used with the
|
|||
|
modification, it is remembered. If a count is given to this command, it
|
|||
|
overrides the remembered count, and is remembered for future uses of
|
|||
|
this command. The cut buffer specification is similarly remembered.</p>
|
|||
|
<p><span id="index-vi_002dreplace_002dchars"></span></p>
|
|||
|
<p><code>vi-replace-chars</code> (unbound) (<code>r</code>) (unbound)</p>
|
|||
|
<p>Replace the character under the cursor with a character read from the
|
|||
|
keyboard.</p>
|
|||
|
<p><span id="index-self_002dinsert"></span></p>
|
|||
|
<p>Insert a character into the buffer at the cursor position.</p>
|
|||
|
<p><span id="index-self_002dinsert_002dunmeta"></span></p>
|
|||
|
<p><code>self-insert-unmeta</code> (<code>ESC-^I ESC-^J ESC-^M</code>) (unbound) (unbound)</p>
|
|||
|
<p>Insert a character into the buffer after stripping the meta bit and
|
|||
|
converting ^M to ^J.</p>
|
|||
|
<p><span id="index-vi_002dsubstitute"></span></p>
|
|||
|
<p><code>vi-substitute</code> (unbound) (<code>s</code>) (unbound)</p>
|
|||
|
<p>Substitute the next character(s).</p>
|
|||
|
<p><span id="index-vi_002dswap_002dcase"></span></p>
|
|||
|
<p><code>vi-swap-case</code> (unbound) (<code>~</code>) (unbound)</p>
|
|||
|
<p>Swap the case of the character under the cursor and move past it.</p>
|
|||
|
<p><span id="index-transpose_002dchars"></span></p>
|
|||
|
<p><code>transpose-chars</code> (<code>^T</code>) (unbound) (unbound)</p>
|
|||
|
<p>Exchange the two characters to the left of the cursor if at end of line,
|
|||
|
else exchange the character under the cursor with the character to the
|
|||
|
left.</p>
|
|||
|
<p><span id="index-transpose_002dwords"></span></p>
|
|||
|
<p><code>transpose-words</code> (<code>ESC-T ESC-t</code>) (unbound) (unbound)</p>
|
|||
|
<p>Exchange the current word with the one before it.</p>
|
|||
|
<p>With a positive numeric argument <em>N</em>, the word around the cursor, or
|
|||
|
following it if the cursor is between words, is transposed with the
|
|||
|
preceding <em>N</em> words. The cursor is put at the end of the resulting group
|
|||
|
of words.</p>
|
|||
|
<p>With a negative numeric argument <em>-N</em>, the effect is the same as using a
|
|||
|
positive argument <em>N</em> except that the original cursor position is
|
|||
|
retained, regardless of how the words are rearranged.</p>
|
|||
|
<p><span id="index-vi_002dunindent"></span></p>
|
|||
|
<p><code>vi-unindent</code> (unbound) (<code><</code>) (unbound)</p>
|
|||
|
<p>Unindent a number of lines.</p>
|
|||
|
<p><span id="index-vi_002dup_002dcase"></span></p>
|
|||
|
<p><code>vi-up-case</code> (unbound) (<code>gU</code>) (unbound)</p>
|
|||
|
<p>Read a movement command from the keyboard, and convert all characters
|
|||
|
from the cursor position to the endpoint of the movement to lowercase.
|
|||
|
If the movement command is <code>vi-up-case</code>, swap the case of all characters
|
|||
|
on the current line.</p>
|
|||
|
<p><span id="index-up_002dcase_002dword"></span></p>
|
|||
|
<p><code>up-case-word</code> (<code>ESC-U ESC-u</code>) (unbound) (unbound)</p>
|
|||
|
<p>Convert the current word to all caps and move past it.</p>
|
|||
|
<p><span id="index-yank"></span></p>
|
|||
|
<p><code>yank</code> (<code>^Y</code>) (unbound) (unbound)</p>
|
|||
|
<p>Insert the contents of the kill buffer at the cursor position.</p>
|
|||
|
<p><span id="index-yank_002dpop"></span></p>
|
|||
|
<p><code>yank-pop</code> (<code>ESC-y</code>) (unbound) (unbound)</p>
|
|||
|
<p>Remove the text just yanked, rotate the kill-ring (the history of
|
|||
|
previously killed text) and yank the new top. Only works following
|
|||
|
<code>yank</code>, <code>vi-put-before</code>, <code>vi-put-after</code> or <code>yank-pop</code>.</p>
|
|||
|
<p><span id="index-vi_002dyank"></span></p>
|
|||
|
<p><code>vi-yank</code> (unbound) (<code>y</code>) (unbound)</p>
|
|||
|
<p>Read a movement command from the keyboard, and copy the region from the
|
|||
|
cursor position to the endpoint of the movement into the kill buffer. If
|
|||
|
the command is <code>vi-yank</code>, copy the current line.</p>
|
|||
|
<p><span id="index-vi_002dyank_002dwhole_002dline"></span></p>
|
|||
|
<p><code>vi-yank-whole-line</code> (unbound) (<code>Y</code>) (unbound)</p>
|
|||
|
<p>Copy the current line into the kill buffer.</p>
|
|||
|
<p><span id="index-vi_002dyank_002deol"></span></p>
|
|||
|
<p><code>vi-yank-eol</code></p>
|
|||
|
<p>Copy the region from the cursor position to the end of the line into the
|
|||
|
kill buffer. Arguably, this is what Y should do in vi, but it isn’t what
|
|||
|
it actually does.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Arguments"></span> <span id="Arguments-1"></span></p>
|
|||
|
<h3 id="1864-arguments"><a class="header" href="#1864-arguments">18.6.4 Arguments</a></h3>
|
|||
|
<p><span id="index-digit_002dargument"></span></p>
|
|||
|
<p><code>digit-argument</code> (<code>ESC-0</code>..<code>ESC-9</code>) (<code>1</code>-<code>9</code>) (unbound)</p>
|
|||
|
<p>Start a new numeric argument, or add to the current one. See also
|
|||
|
<code>vi-digit-or-beginning-of-line</code>. This only works if bound to a key
|
|||
|
sequence ending in a decimal digit.</p>
|
|||
|
<p>Inside a widget function, a call to this function treats the last key of
|
|||
|
the key sequence which called the widget as the digit.</p>
|
|||
|
<p><span id="index-neg_002dargument"></span></p>
|
|||
|
<p><code>neg-argument</code> (<code>ESC-``-</code>) (unbound) (unbound)</p>
|
|||
|
<p>Changes the sign of the following argument.</p>
|
|||
|
<p><span id="index-universal_002dargument"></span></p>
|
|||
|
<p><code>universal-argument</code></p>
|
|||
|
<p>Multiply the argument of the next command by 4. Alternatively, if this
|
|||
|
command is followed by an integer (positive or negative), use that as
|
|||
|
the argument for the next command. Thus digits cannot be repeated using
|
|||
|
this command. For example, if this command occurs twice, followed
|
|||
|
immediately by <code>forward-char</code>, move forward sixteen spaces; if instead
|
|||
|
it is followed by <code>-2</code>, then <code>forward-char</code>, move backward two spaces.</p>
|
|||
|
<p>Inside a widget function, if passed an argument, i.e. ‘<code>zle universal-argument</code> <code>num</code>’, the numeric argument will be set to <code>num</code>;
|
|||
|
this is equivalent to ‘<code>NUMERIC=``num</code>’.</p>
|
|||
|
<p><span id="index-argument_002dbase"></span></p>
|
|||
|
<p><code>argument-base</code></p>
|
|||
|
<p>Use the existing numeric argument as a numeric base, which must be in
|
|||
|
the range 2 to 36 inclusive. Subsequent use of <code>digit-argument</code> and
|
|||
|
<code>universal-argument</code> will input a new numeric argument in the given
|
|||
|
base. The usual hexadecimal convention is used: the letter <code>a</code> or <code>A</code>
|
|||
|
corresponds to 10, and so on. Arguments in bases requiring digits from
|
|||
|
10 upwards are more conveniently input with <code>universal-argument</code>, since
|
|||
|
<code>ESC-a</code> etc. are not usually bound to <code>digit-argument</code>.</p>
|
|||
|
<p>The function can be used with a command argument inside a user-defined
|
|||
|
widget. The following code sets the base to 16 and lets the user input a
|
|||
|
hexadecimal argument until a key out of the digit range is typed:</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle argument-base 16
|
|||
|
zle universal-argument
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<hr />
|
|||
|
<p><span id="Completion"></span> <span id="Completion-2"></span></p>
|
|||
|
<h3 id="1865-completion"><a class="header" href="#1865-completion">18.6.5 Completion</a></h3>
|
|||
|
<p><span id="index-accept_002dand_002dmenu_002dcomplete"></span></p>
|
|||
|
<p><code>accept-and-menu-complete</code></p>
|
|||
|
<p>In a menu completion, insert the current completion into the buffer, and
|
|||
|
advance to the next possible completion.</p>
|
|||
|
<p><span id="index-complete_002dword"></span></p>
|
|||
|
<p><code>complete-word</code></p>
|
|||
|
<p>Attempt completion on the current word.</p>
|
|||
|
<p><span id="index-delete_002dchar_002dor_002dlist"></span></p>
|
|||
|
<p><code>delete-char-or-list</code> (<code>^D</code>) (unbound) (unbound)</p>
|
|||
|
<p>Delete the character under the cursor. If the cursor is at the end of
|
|||
|
the line, list possible completions for the current word.</p>
|
|||
|
<p><span id="index-expand_002dcmd_002dpath"></span></p>
|
|||
|
<p><code>expand-cmd-path</code></p>
|
|||
|
<p>Expand the current command to its full pathname.</p>
|
|||
|
<p><span id="index-expand_002dor_002dcomplete"></span></p>
|
|||
|
<p><code>expand-or-complete</code> (<code>TAB</code>) (unbound) (<code>TAB</code>)</p>
|
|||
|
<p>Attempt shell expansion on the current word. If that fails, attempt
|
|||
|
completion.</p>
|
|||
|
<p><span id="index-expand_002dor_002dcomplete_002dprefix"></span></p>
|
|||
|
<p><code>expand-or-complete-prefix</code></p>
|
|||
|
<p>Attempt shell expansion on the current word up to cursor.</p>
|
|||
|
<p><span id="index-expand_002dhistory"></span></p>
|
|||
|
<p><code>expand-history</code> (<code>ESC-space ESC-!</code>) (unbound) (unbound)</p>
|
|||
|
<p>Perform history expansion on the edit buffer.</p>
|
|||
|
<p><span id="index-expand_002dword"></span></p>
|
|||
|
<p><code>expand-word</code> (<code>^X*</code>) (unbound) (unbound)</p>
|
|||
|
<p>Attempt shell expansion on the current word.</p>
|
|||
|
<p><span id="index-list_002dchoices"></span></p>
|
|||
|
<p><code>list-choices</code> (<code>ESC-^D</code>) (<code>^D =</code>) (<code>^D</code>)</p>
|
|||
|
<p>List possible completions for the current word.</p>
|
|||
|
<p><span id="index-list_002dexpand"></span></p>
|
|||
|
<p><code>list-expand</code> (<code>^Xg ^XG</code>) (<code>^G</code>) (<code>^G</code>)</p>
|
|||
|
<p>List the expansion of the current word.</p>
|
|||
|
<p><span id="index-magic_002dspace"></span></p>
|
|||
|
<p><code>magic-space</code></p>
|
|||
|
<p>Perform history expansion and insert a space into the buffer. This is
|
|||
|
intended to be bound to space.</p>
|
|||
|
<p><span id="index-menu_002dcomplete"></span>
|
|||
|
<span id="index-MENU_005fCOMPLETE_002c-use-of"></span></p>
|
|||
|
<p><code>menu-complete</code></p>
|
|||
|
<p>Like <code>complete-word</code>, except that menu completion is used. See the
|
|||
|
<code>MENU_COMPLETE</code> option.</p>
|
|||
|
<p><span id="index-menu_002dexpand_002dor_002dcomplete"></span></p>
|
|||
|
<p><code>menu-expand-or-complete</code></p>
|
|||
|
<p>Like <code>expand-or-complete</code>, except that menu completion is used.</p>
|
|||
|
<p><span id="index-reverse_002dmenu_002dcomplete"></span></p>
|
|||
|
<p><code>reverse-menu-complete</code></p>
|
|||
|
<p>Perform menu completion, like <code>menu-complete</code>, except that if a menu
|
|||
|
completion is already in progress, move to the <em>previous</em> completion
|
|||
|
rather than the next.</p>
|
|||
|
<p><span id="index-end_002dof_002dlist"></span></p>
|
|||
|
<p><code>end-of-list</code></p>
|
|||
|
<p>When a previous completion displayed a list below the prompt, this
|
|||
|
widget can be used to move the prompt below the list.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Miscellaneous"></span> <span id="Miscellaneous-1"></span></p>
|
|||
|
<h3 id="1866-miscellaneous"><a class="header" href="#1866-miscellaneous">18.6.6 Miscellaneous</a></h3>
|
|||
|
<p><span id="index-accept_002dand_002dhold"></span></p>
|
|||
|
<p><code>accept-and-hold</code> (<code>ESC-A ESC-a</code>) (unbound) (unbound)</p>
|
|||
|
<p>Push the contents of the buffer on the buffer stack and execute it.</p>
|
|||
|
<p><span id="index-accept_002dand_002dinfer_002dnext_002dhistory"></span></p>
|
|||
|
<p><code>accept-and-infer-next-history</code></p>
|
|||
|
<p>Execute the contents of the buffer. Then search the history list for a
|
|||
|
line matching the current one and push the event following onto the
|
|||
|
buffer stack.</p>
|
|||
|
<p><span id="index-accept_002dline"></span></p>
|
|||
|
<p><code>accept-line</code> (<code>^J ^M</code>) (<code>^J ^M</code>) (<code>^J ^M</code>)</p>
|
|||
|
<p>Finish editing the buffer. Normally this causes the buffer to be
|
|||
|
executed as a shell command.</p>
|
|||
|
<p><span id="index-accept_002dline_002dand_002ddown_002dhistory"></span></p>
|
|||
|
<p><code>accept-line-and-down-history</code> (<code>^O</code>) (unbound) (unbound)</p>
|
|||
|
<p>Execute the current line, and push the next history event on the buffer
|
|||
|
stack.</p>
|
|||
|
<p><span id="index-auto_002dsuffix_002dremove"></span></p>
|
|||
|
<p><code>auto-suffix-remove</code></p>
|
|||
|
<p>If the previous action added a suffix (space, slash, etc.) to the word
|
|||
|
on the command line, remove it. Otherwise do nothing. Removing the
|
|||
|
suffix ends any active menu completion or menu selection.</p>
|
|||
|
<p>This widget is intended to be called from user-defined widgets to
|
|||
|
enforce a desired suffix-removal behavior.</p>
|
|||
|
<p><span id="index-auto_002dsuffix_002dretain"></span></p>
|
|||
|
<p><code>auto-suffix-retain</code></p>
|
|||
|
<p>If the previous action added a suffix (space, slash, etc.) to the word
|
|||
|
on the command line, force it to be preserved. Otherwise do nothing.
|
|||
|
Retaining the suffix ends any active menu completion or menu selection.</p>
|
|||
|
<p>This widget is intended to be called from user-defined widgets to
|
|||
|
enforce a desired suffix-preservation behavior.</p>
|
|||
|
<p><span id="index-beep"></span></p>
|
|||
|
<p><code>beep</code></p>
|
|||
|
<p>Beep, unless the <code>BEEP</code> option is unset.</p>
|
|||
|
<p><span id="index-bracketed_002dpaste"></span></p>
|
|||
|
<p><code>bracketed-paste</code></p>
|
|||
|
<p>This widget is invoked when text is pasted to the terminal emulator. It
|
|||
|
is not intended to be bound to actual keys but instead to the special
|
|||
|
sequence generated by the terminal emulator when text is pasted.</p>
|
|||
|
<p>When invoked interactively, the pasted text is inserted to the buffer
|
|||
|
and placed in the cutbuffer. If a numeric argument is given, shell
|
|||
|
quoting will be applied to the pasted text before it is inserted.</p>
|
|||
|
<p>When a named buffer is specified with <code>vi-set-buffer</code> (<code>"x</code>), the pasted
|
|||
|
text is stored in that named buffer but not inserted.</p>
|
|||
|
<p>When called from a widget function as ‘<code>bracketed-paste</code> <code>name</code>‘, the
|
|||
|
pasted text is assigned to the variable <code>name</code> and no other processing
|
|||
|
is done.</p>
|
|||
|
<p>See also the <code>zle_bracketed_paste</code> parameter.</p>
|
|||
|
<p><span id="index-vi_002dcmd_002dmode"></span></p>
|
|||
|
<p><code>vi-cmd-mode</code> (<code>^X^V</code>) (unbound) (<code>^[</code>)</p>
|
|||
|
<p>Enter command mode; that is, select the ‘<code>vicmd</code>’ keymap. Yes, this is
|
|||
|
bound by default in emacs mode.</p>
|
|||
|
<p><span id="index-vi_002dcaps_002dlock_002dpanic"></span></p>
|
|||
|
<p><code>vi-caps-lock-panic</code></p>
|
|||
|
<p>Hang until any lowercase key is pressed. This is for vi users without
|
|||
|
the mental capacity to keep track of their caps lock key (like the
|
|||
|
author).</p>
|
|||
|
<p><span id="index-clear_002dscreen"></span></p>
|
|||
|
<p><code>clear-screen</code> (<code>^L ESC-^L</code>) (<code>^L</code>) (<code>^L</code>)</p>
|
|||
|
<p>Clear the screen and redraw the prompt.</p>
|
|||
|
<p><span id="index-deactivate_002dregion"></span></p>
|
|||
|
<p><code>deactivate-region</code></p>
|
|||
|
<p>Make the current region inactive. This disables vim-style visual
|
|||
|
selection mode if it is active.</p>
|
|||
|
<p><span id="index-describe_002dkey_002dbriefly"></span></p>
|
|||
|
<p><code>describe-key-briefly</code></p>
|
|||
|
<p>Reads a key sequence, then prints the function bound to that sequence.</p>
|
|||
|
<p><span id="index-exchange_002dpoint_002dand_002dmark"></span></p>
|
|||
|
<p><code>exchange-point-and-mark</code> (<code>^X^X</code>) (unbound) (unbound)</p>
|
|||
|
<p>Exchange the cursor position (point) with the position of the mark.
|
|||
|
Unless a negative numeric argument is given, the region between point
|
|||
|
and mark is activated so that it can be highlighted. If a zero numeric
|
|||
|
argument is given, the region is activated but point and mark are not
|
|||
|
swapped.</p>
|
|||
|
<p><span id="index-execute_002dnamed_002dcmd"></span></p>
|
|||
|
<p><code>execute-named-cmd</code> (<code>ESC-x</code>) (<code>:</code>) (unbound)</p>
|
|||
|
<p>Read the name of an editor command and execute it. Aliasing this widget
|
|||
|
with ‘<code>zle -A</code>’ or replacing it with ‘<code>zle -N</code>’ has no effect when
|
|||
|
interpreting key bindings, but ‘<code>zle execute-named-cmd</code>’ will invoke
|
|||
|
such an alias or replacement.</p>
|
|||
|
<p>A restricted set of editing functions is available in the mini-buffer.
|
|||
|
Keys are looked up in the special <code>command</code> keymap, and if not found
|
|||
|
there in the main keymap. An interrupt signal, as defined by the stty
|
|||
|
setting, will abort the function. Note that the following always perform
|
|||
|
the same task within the <code>executed-named-cmd</code> environment and cannot be
|
|||
|
replaced by user defined widgets, nor can the set of functions be
|
|||
|
extended. The allowed functions are: <code>backward-delete-char</code>,
|
|||
|
<code>vi-backward-delete-char</code>, <code>clear-screen</code>, <code>redisplay</code>, <code>quoted-insert</code>,
|
|||
|
<code>vi-quoted-insert</code>, <code>backward-kill-word</code>, <code>vi-backward-kill-word</code>,
|
|||
|
<code>kill-whole-line</code>, <code>vi-kill-line</code>, <code>backward-kill-line</code>, <code>list-choices</code>,
|
|||
|
<code>delete-char-or-list</code>, <code>complete-word</code>, <code>accept-line</code>,
|
|||
|
<code>expand-or-complete</code> and <code>expand-or-complete-prefix</code>.</p>
|
|||
|
<p><code>kill-region</code> kills the last word, and vi-cmd-mode is treated the same
|
|||
|
as accept-line. The space and tab characters, if not bound to one of
|
|||
|
these functions, will complete the name and then list the possibilities
|
|||
|
if the <code>AUTO_LIST</code> option is set. Any other character that is not bound
|
|||
|
to <code>self-insert</code> or <code>self-insert-unmeta</code> will beep and be ignored. The
|
|||
|
bindings of the current insert mode will be used.</p>
|
|||
|
<p>Currently this command may not be redefined or called by name.</p>
|
|||
|
<p><span id="index-execute_002dlast_002dnamed_002dcmd"></span></p>
|
|||
|
<p><code>execute-last-named-cmd</code> (<code>ESC-z</code>) (unbound) (unbound)</p>
|
|||
|
<p>Redo the last function executed with <code>execute-named-cmd</code>.</p>
|
|||
|
<p>Like <code>execute-named-cmd</code>, this command may not be redefined, but it may
|
|||
|
be called by name.</p>
|
|||
|
<p><span id="index-get_002dline"></span></p>
|
|||
|
<p><code>get-line</code> (<code>ESC-G ESC-g</code>) (unbound) (unbound)</p>
|
|||
|
<p>Pop the top line off the buffer stack and insert it at the cursor
|
|||
|
position.</p>
|
|||
|
<p><span id="index-pound_002dinsert"></span></p>
|
|||
|
<p><code>pound-insert</code> (unbound) (<code>#</code>) (unbound)</p>
|
|||
|
<p>If there is no # character at the beginning of the buffer, add one to
|
|||
|
the beginning of each line. If there is one, remove a # from each line
|
|||
|
that has one. In either case, accept the current line. The
|
|||
|
<code>INTERACTIVE_COMMENTS</code> option must be set for this to have any
|
|||
|
usefulness.</p>
|
|||
|
<p><span id="index-vi_002dpound_002dinsert"></span></p>
|
|||
|
<p><code>vi-pound-insert</code></p>
|
|||
|
<p>If there is no # character at the beginning of the current line, add
|
|||
|
one. If there is one, remove it. The <code>INTERACTIVE_COMMENTS</code> option must
|
|||
|
be set for this to have any usefulness.</p>
|
|||
|
<p><span id="index-push_002dinput"></span></p>
|
|||
|
<p><code>push-input</code></p>
|
|||
|
<p>Push the entire current multiline construct onto the buffer stack and
|
|||
|
return to the top-level (<code>PS1</code>) prompt. If the current parser construct
|
|||
|
is only a single line, this is exactly like <code>push-line</code>. Next time the
|
|||
|
editor starts up or is popped with <code>get-line</code>, the construct will be
|
|||
|
popped off the top of the buffer stack and loaded into the editing
|
|||
|
buffer.</p>
|
|||
|
<p><span id="index-push_002dline"></span></p>
|
|||
|
<p><code>push-line</code> (<code>^Q ESC-Q ESC-q</code>) (unbound) (unbound)</p>
|
|||
|
<p>Push the current buffer onto the buffer stack and clear the buffer. Next
|
|||
|
time the editor starts up, the buffer will be popped off the top of the
|
|||
|
buffer stack and loaded into the editing buffer.</p>
|
|||
|
<p><span id="index-push_002dline_002dor_002dedit"></span></p>
|
|||
|
<p><code>push-line-or-edit</code></p>
|
|||
|
<p>At the top-level (<code>PS1</code>) prompt, equivalent to <code>push-line</code>. At a
|
|||
|
secondary (<code>PS2</code>) prompt, move the entire current multiline construct
|
|||
|
into the editor buffer. The latter is equivalent to <code>push-input</code>
|
|||
|
followed by <code>get-line</code>.</p>
|
|||
|
<p><span id="index-read_002dcommand"></span></p>
|
|||
|
<p><code>read-command</code></p>
|
|||
|
<p>Only useful from a user-defined widget. A keystroke is read just as in
|
|||
|
normal operation, but instead of the command being executed the name of
|
|||
|
the command that would be executed is stored in the shell parameter
|
|||
|
<code>REPLY</code>. This can be used as the argument of a future <code>zle</code> command. If
|
|||
|
the key sequence is not bound, status 1 is returned; typically, however,
|
|||
|
<code>REPLY</code> is set to <code>undefined-key</code> to indicate a useless key sequence.</p>
|
|||
|
<p><span id="index-recursive_002dedit"></span></p>
|
|||
|
<p><code>recursive-edit</code></p>
|
|||
|
<p>Only useful from a user-defined widget. At this point in the function,
|
|||
|
the editor regains control until one of the standard widgets which would
|
|||
|
normally cause zle to exit (typically an <code>accept-line</code> caused by hitting
|
|||
|
the return key) is executed. Instead, control returns to the
|
|||
|
user-defined widget. The status returned is non-zero if the return was
|
|||
|
caused by an error, but the function still continues executing and hence
|
|||
|
may tidy up. This makes it safe for the user-defined widget to alter the
|
|||
|
command line or key bindings temporarily.</p>
|
|||
|
<p>The following widget, <code>caps-lock</code>, serves as an example.</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">self-insert-ucase() {
|
|||
|
LBUFFER+=${(U)KEYS[-1]}
|
|||
|
}
|
|||
|
|
|||
|
integer stat
|
|||
|
|
|||
|
zle -N self-insert self-insert-ucase
|
|||
|
zle -A caps-lock save-caps-lock
|
|||
|
zle -A accept-line caps-lock
|
|||
|
|
|||
|
zle recursive-edit
|
|||
|
stat=$?
|
|||
|
|
|||
|
zle -A .self-insert self-insert
|
|||
|
zle -A save-caps-lock caps-lock
|
|||
|
zle -D save-caps-lock
|
|||
|
|
|||
|
(( stat )) && zle send-break
|
|||
|
|
|||
|
return $stat
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>This causes typed letters to be inserted capitalised until either
|
|||
|
<code>accept-line</code> (i.e. typically the return key) is typed or the
|
|||
|
<code>caps-lock</code> widget is invoked again; the later is handled by saving the
|
|||
|
old definition of <code>caps-lock</code> as <code>save-caps-lock</code> and then rebinding it
|
|||
|
to invoke <code>accept-line</code>. Note that an error from the recursive edit is
|
|||
|
detected as a non-zero return status and propagated by using the
|
|||
|
<code>send-break</code> widget.</p>
|
|||
|
<p><span id="index-redisplay"></span></p>
|
|||
|
<p><code>redisplay</code> (unbound) (<code>^R</code>) (<code>^R</code>)</p>
|
|||
|
<p>Redisplays the edit buffer.</p>
|
|||
|
<p><span id="index-reset_002dprompt"></span></p>
|
|||
|
<p><code>reset-prompt</code> (unbound) (unbound) (unbound)</p>
|
|||
|
<p>Force the prompts on both the left and right of the screen to be
|
|||
|
re-expanded, then redisplay the edit buffer. This reflects changes both
|
|||
|
to the prompt variables themselves and changes in the expansion of the
|
|||
|
values (for example, changes in time or directory, or changes to the
|
|||
|
value of variables referred to by the prompt).</p>
|
|||
|
<p>Otherwise, the prompt is only expanded each time zle starts, and when
|
|||
|
the display has been interrupted by output from another part of the
|
|||
|
shell (such as a job notification) which causes the command line to be
|
|||
|
reprinted.</p>
|
|||
|
<p><code>reset-prompt</code> doesn’t alter the special parameter <code>LASTWIDGET</code>.</p>
|
|||
|
<p><span id="index-send_002dbreak"></span></p>
|
|||
|
<p><code>send-break</code> (<code>^G ESC-^G</code>) (unbound) (unbound)</p>
|
|||
|
<p>Abort the current editor function, e.g. <code>execute-named-command</code>, or the
|
|||
|
editor itself, e.g. if you are in <code>vared</code>. Otherwise abort the parsing
|
|||
|
of the current line; in this case the aborted line is available in the
|
|||
|
shell variable <code>ZLE_LINE_ABORTED</code>. If the editor is aborted from within
|
|||
|
<code>vared</code>, the variable <code>ZLE_VARED_ABORTED</code> is set.</p>
|
|||
|
<p><span id="index-run_002dhelp"></span></p>
|
|||
|
<p><code>run-help</code> (<code>ESC-H ESC-h</code>) (unbound) (unbound)</p>
|
|||
|
<p>Push the buffer onto the buffer stack, and execute the command
|
|||
|
‘<code>run-help</code> <code>cmd</code>’, where <code>cmd</code> is the current command. <code>run-help</code> is
|
|||
|
normally aliased to <code>man</code>.</p>
|
|||
|
<p><span id="index-vi_002dset_002dbuffer"></span></p>
|
|||
|
<p><code>vi-set-buffer</code> (unbound) (<code>"</code>) (unbound)</p>
|
|||
|
<p>Specify a buffer to be used in the following command. There are 37
|
|||
|
buffers that can be specified: the 26 ‘named’ buffers <code>"a</code> to <code>"z</code>, the
|
|||
|
‘yank’ buffer <code>"0</code>, the nine ‘queued’ buffers <code>"1</code> to <code>"9</code> and the
|
|||
|
‘black hole’ buffer <code>"_</code>. The named buffers can also be specified as
|
|||
|
<code>"A</code> to <code>"Z</code>.</p>
|
|||
|
<p>When a buffer is specified for a cut, change or yank command, the text
|
|||
|
concerned replaces the previous contents of the specified buffer. If a
|
|||
|
named buffer is specified using a capital, the newly cut text is
|
|||
|
appended to the buffer instead of overwriting it. When using the <code>"_</code>
|
|||
|
buffer, nothing happens. This can be useful for deleting text without
|
|||
|
affecting any buffers.</p>
|
|||
|
<p>If no buffer is specified for a cut or change command, <code>"1</code> is used, and
|
|||
|
the contents of <code>"1</code> to <code>"8</code> are each shifted along one buffer; the
|
|||
|
contents of <code>"9</code> is lost. If no buffer is specified for a yank command,
|
|||
|
<code>"0</code> is used. Finally, a paste command without a specified buffer will
|
|||
|
paste the text from the most recent command regardless of any buffer
|
|||
|
that might have been used with that command.</p>
|
|||
|
<p>When called from a widget function by the <code>zle</code> command, the buffer can
|
|||
|
optionally be specified with an argument. For example,</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle vi-set-buffer A
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p><span id="index-vi_002dset_002dmark"></span></p>
|
|||
|
<p><code>vi-set-mark</code> (unbound) (<code>m</code>) (unbound)</p>
|
|||
|
<p>Set the specified mark at the cursor position.</p>
|
|||
|
<p><span id="index-set_002dmark_002dcommand"></span></p>
|
|||
|
<p><code>set-mark-command</code> (<code>^@</code>) (unbound) (unbound)</p>
|
|||
|
<p>Set the mark at the cursor position. If called with a negative numeric
|
|||
|
argument, do not set the mark but deactivate the region so that it is no
|
|||
|
longer highlighted (it is still usable for other purposes). Otherwise
|
|||
|
the region is marked as active.</p>
|
|||
|
<p><span id="index-spell_002dword"></span></p>
|
|||
|
<p><code>spell-word</code> (<code>ESC-$ ESC-S ESC-s</code>) (unbound) (unbound)</p>
|
|||
|
<p>Attempt spelling correction on the current word.</p>
|
|||
|
<p><span id="index-split_002dundo"></span></p>
|
|||
|
<p><code>split-undo</code></p>
|
|||
|
<p>Breaks the undo sequence at the current change. This is useful in vi
|
|||
|
mode as changes made in insert mode are coalesced on entering command
|
|||
|
mode. Similarly, <code>undo</code> will normally revert as one all the changes made
|
|||
|
by a user-defined widget.</p>
|
|||
|
<p><span id="index-undefined_002dkey"></span></p>
|
|||
|
<p><code>undefined-key</code></p>
|
|||
|
<p>This command is executed when a key sequence that is not bound to any
|
|||
|
command is typed. By default it beeps.</p>
|
|||
|
<p><span id="index-undo"></span></p>
|
|||
|
<p><code>undo</code> (<code>^_ ^Xu ^X^U</code>) (<code>u</code>) (unbound)</p>
|
|||
|
<p>Incrementally undo the last text modification. When called from a
|
|||
|
user-defined widget, takes an optional argument indicating a previous
|
|||
|
state of the undo history as returned by the <code>UNDO_CHANGE_NO</code> variable;
|
|||
|
modifications are undone until that state is reached, subject to any
|
|||
|
limit imposed by the <code>UNDO_LIMIT_NO</code> variable.</p>
|
|||
|
<p>Note that when invoked from vi command mode, the full prior change made
|
|||
|
in insert mode is reverted, the changes having been merged when command
|
|||
|
mode was selected.</p>
|
|||
|
<p><span id="index-redo"></span></p>
|
|||
|
<p><code>redo</code> (unbound) (<code>^R</code>) (unbound)</p>
|
|||
|
<p>Incrementally redo undone text modifications.</p>
|
|||
|
<p><span id="index-vi_002dundo_002dchange"></span></p>
|
|||
|
<p><code>vi-undo-change</code> (unbound) (unbound) (unbound)</p>
|
|||
|
<p>Undo the last text modification. If repeated, redo the modification.</p>
|
|||
|
<p><span id="index-visual_002dmode"></span></p>
|
|||
|
<p><code>visual-mode</code> (unbound) (<code>v</code>) (unbound)</p>
|
|||
|
<p>Toggle vim-style visual selection mode. If line-wise visual mode is
|
|||
|
currently enabled then it is changed to being character-wise. If used
|
|||
|
following an operator, it forces the subsequent movement command to be
|
|||
|
treated as a character-wise movement.</p>
|
|||
|
<p><span id="index-visual_002dline_002dmode"></span></p>
|
|||
|
<p><code>visual-line-mode</code> (unbound) (<code>V</code>) (unbound)</p>
|
|||
|
<p>Toggle vim-style line-wise visual selection mode. If character-wise
|
|||
|
visual mode is currently enabled then it is changed to being line-wise.
|
|||
|
If used following an operator, it forces the subsequent movement command
|
|||
|
to be treated as a line-wise movement.</p>
|
|||
|
<p><span id="index-what_002dcursor_002dposition"></span></p>
|
|||
|
<p><code>what-cursor-position</code> (<code>^X=</code>) (<code>ga</code>) (unbound)</p>
|
|||
|
<p>Print the character under the cursor, its code as an octal, decimal and
|
|||
|
hexadecimal number, the current cursor position within the buffer and
|
|||
|
the column of the cursor in the current line.</p>
|
|||
|
<p><span id="index-where_002dis"></span></p>
|
|||
|
<p><code>where-is</code></p>
|
|||
|
<p>Read the name of an editor command and print the listing of key
|
|||
|
sequences that invoke the specified command. A restricted set of editing
|
|||
|
functions is available in the mini-buffer. Keys are looked up in the
|
|||
|
special <code>command</code> keymap, and if not found there in the main keymap.</p>
|
|||
|
<p><span id="index-which_002dcommand"></span></p>
|
|||
|
<p><code>which-command</code> (<code>ESC-?</code>) (unbound) (unbound)</p>
|
|||
|
<p>Push the buffer onto the buffer stack, and execute the command
|
|||
|
‘<code>which-command</code> <code>cmd</code>’. where <code>cmd</code> is the current command.
|
|||
|
<code>which-command</code> is normally aliased to <code>whence</code>.</p>
|
|||
|
<p><span id="index-vi_002ddigit_002dor_002dbeginning_002dof_002dline"></span></p>
|
|||
|
<p><code>vi-digit-or-beginning-of-line</code> (unbound) (<code>0</code>) (unbound)</p>
|
|||
|
<p>If the last command executed was a digit as part of an argument,
|
|||
|
continue the argument. Otherwise, execute vi-beginning-of-line.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Text-Objects"></span> <span id="Text-Objects-1"></span></p>
|
|||
|
<h3 id="1867-text-objects"><a class="header" href="#1867-text-objects">18.6.7 Text Objects</a></h3>
|
|||
|
<p><span id="index-text-objects"></span></p>
|
|||
|
<p>Text objects are commands that can be used to select a block of text
|
|||
|
according to some criteria. They are a feature of the vim text editor
|
|||
|
and so are primarily intended for use with vi operators or from visual
|
|||
|
selection mode. However, they can also be used from vi-insert or emacs
|
|||
|
mode. Key bindings listed below apply to the <code>viopp</code> and <code>visual</code>
|
|||
|
keymaps.</p>
|
|||
|
<p><span id="index-select_002da_002dblank_002dword"></span></p>
|
|||
|
<p><code>select-a-blank-word</code> (<code>aW</code>)</p>
|
|||
|
<p>Select a word including adjacent blanks, where a word is defined as a
|
|||
|
series of non-blank characters. With a numeric argument, multiple words
|
|||
|
will be selected.</p>
|
|||
|
<p><span id="index-select_002da_002dshell_002dword"></span></p>
|
|||
|
<p><code>select-a-shell-word</code> (<code>aa</code>)</p>
|
|||
|
<p>Select the current command argument applying the normal rules for
|
|||
|
quoting.</p>
|
|||
|
<p><span id="index-select_002da_002dword"></span></p>
|
|||
|
<p><code>select-a-word</code> (<code>aw</code>)</p>
|
|||
|
<p>Select a word including adjacent blanks, using the normal vi-style word
|
|||
|
definition. With a numeric argument, multiple words will be selected.</p>
|
|||
|
<p><span id="index-select_002din_002dblank_002dword"></span></p>
|
|||
|
<p><code>select-in-blank-word</code> (<code>iW</code>)</p>
|
|||
|
<p>Select a word, where a word is defined as a series of non-blank
|
|||
|
characters. With a numeric argument, multiple words will be selected.</p>
|
|||
|
<p><span id="index-select_002din_002dshell_002dword"></span></p>
|
|||
|
<p><code>select-in-shell-word</code> (<code>ia</code>)</p>
|
|||
|
<p>Select the current command argument applying the normal rules for
|
|||
|
quoting. If the argument begins and ends with matching quote characters,
|
|||
|
these are not included in the selection.</p>
|
|||
|
<p><span id="index-select_002din_002dword"></span></p>
|
|||
|
<p><code>select-in-word</code> (<code>iw</code>)</p>
|
|||
|
<p>Select a word, using the normal vi-style word definition. With a numeric
|
|||
|
argument, multiple words will be selected.</p>
|
|||
|
<hr />
|
|||
|
<p><span id="Character-Highlighting"></span>
|
|||
|
<span id="Character-Highlighting-1"></span></p>
|
|||
|
<h2 id="187-character-highlighting"><a class="header" href="#187-character-highlighting">18.7 Character Highlighting</a></h2>
|
|||
|
<p><span id="index-zle_005fhighlight_002c-setting"></span></p>
|
|||
|
<p>The line editor has the ability to highlight characters or regions of
|
|||
|
the line that have a particular significance. This is controlled by the
|
|||
|
array parameter <code>zle_highlight</code>, if it has been set by the user.</p>
|
|||
|
<p>If the parameter contains the single entry <code>none</code> all highlighting is
|
|||
|
turned off. Note the parameter is still expected to be an array.</p>
|
|||
|
<p>Otherwise each entry of the array should consist of a word indicating a
|
|||
|
context for highlighting, then a colon, then a comma-separated list of
|
|||
|
the types of highlighting to apply in that context.</p>
|
|||
|
<p>The contexts available for highlighting are the following:</p>
|
|||
|
<p><span id="index-region_002c-highlighting"></span>
|
|||
|
<span id="index-highlighting_002c-region"></span></p>
|
|||
|
<p><code>default</code></p>
|
|||
|
<p>Any text within the command line not affected by any other highlighting.</p>
|
|||
|
<p><code>isearch</code></p>
|
|||
|
<p>When one of the incremental history search widgets is active, the area
|
|||
|
of the command line matched by the search string or pattern.</p>
|
|||
|
<p><code>region</code></p>
|
|||
|
<p>The currently selected text. In emacs terminology, this is referred to
|
|||
|
as the region and is bounded by the cursor (point) and the mark. The
|
|||
|
region is only highlighted if it is active, which is the case after the
|
|||
|
mark is modified with <code>set-mark-command</code> or <code>exchange-point-and-mark</code>.
|
|||
|
Note that whether or not the region is active has no effect on its use
|
|||
|
within emacs style widgets, it simply determines whether it is
|
|||
|
highlighted. In vi mode, the region corresponds to selected text in
|
|||
|
visual mode.</p>
|
|||
|
<p><span id="index-special-characters_002c-highlighting"></span>
|
|||
|
<span id="index-highlighting_002c-special-characters"></span></p>
|
|||
|
<p><code>special</code></p>
|
|||
|
<p>representation but are shown in a special manner by the line editor.
|
|||
|
These characters are described below.</p>
|
|||
|
<p><span id="index-completion-removable-suffix_002c-highlighting"></span>
|
|||
|
<span id="index-suffix_002c-highlighting-removable_002c-in-completion"></span>
|
|||
|
<span id="index-removable-suffix_002c-highlighting-in-completion"></span></p>
|
|||
|
<p><code>suffix</code></p>
|
|||
|
<p>This context is used in completion for characters that are marked as
|
|||
|
suffixes that will be removed if the completion ends at that point, the
|
|||
|
most obvious example being a slash (<code>/</code>) after a directory name. Note
|
|||
|
that suffix removal is configurable; the circumstances under which the
|
|||
|
suffix will be removed may differ for different completions.</p>
|
|||
|
<p><code>paste</code></p>
|
|||
|
<p>Following a command to paste text, the characters that were inserted.</p>
|
|||
|
<p>When <code>region_highlight</code> is set, the contexts that describe a region —
|
|||
|
<code>isearch</code>, <code>region</code>, <code>suffix</code>, and <code>paste</code> — are applied first, then
|
|||
|
<code>region_highlight</code> is applied, then the remaining <code>zle_highlight</code>
|
|||
|
contexts are applied. If a particular character is affected by multiple
|
|||
|
specifications, the last specification wins.</p>
|
|||
|
<p><code>zle_highlight</code> may contain additional fields for controlling how
|
|||
|
terminal sequences to change colours are output. Each of the following
|
|||
|
is followed by a colon and a string in the same form as for key
|
|||
|
bindings. This will not be necessary for the vast majority of terminals
|
|||
|
as the defaults shown in parentheses are widely used.</p>
|
|||
|
<p><span id="index-escape-sequences_002c-terminal_002c-for-highlighting"></span>
|
|||
|
<span id="index-terminal-escape-sequences-for-highlighting"></span></p>
|
|||
|
<p><code>fg_start_code</code> (<code>\e[3</code>)</p>
|
|||
|
<p>The start of the escape sequence for the foreground colour. This is
|
|||
|
followed by one to three ASCII digits representing the colour. Only used
|
|||
|
for palette colors, i.e. not 24-bit colors specified via a color
|
|||
|
triplet.</p>
|
|||
|
<p><code>fg_default_code</code> (<code>9</code>)</p>
|
|||
|
<p>The number to use instead of the colour to reset the default foreground
|
|||
|
colour.</p>
|
|||
|
<p><code>fg_end_code</code> (<code>m</code>)</p>
|
|||
|
<p>The end of the escape sequence for the foreground colour.</p>
|
|||
|
<p><code>bg_start_code</code> (<code>\e[4</code>)</p>
|
|||
|
<p>The start of the escape sequence for the background colour. See
|
|||
|
<code>fg_start_code</code> above.</p>
|
|||
|
<p><code>bg_default_code</code> (<code>9</code>)</p>
|
|||
|
<p>The number to use instead of the colour to reset the default background
|
|||
|
colour.</p>
|
|||
|
<p><code>bg_end_code</code> (<code>m</code>)</p>
|
|||
|
<p>The end of the escape sequence for the background colour.</p>
|
|||
|
<p>The available types of highlighting are the following. Note that not all
|
|||
|
types of highlighting are available on all terminals:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p><code>none</code><br />
|
|||
|
No highlighting is applied to the given context. It is not useful
|
|||
|
for this to appear with other types of highlighting; it is used to
|
|||
|
override a default.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>fg=``colour</code><br />
|
|||
|
The foreground colour should be set to <code>colour</code>, a decimal integer,
|
|||
|
the name of one of the eight most widely-supported colours or as a
|
|||
|
‘<code>#</code>’ followed by an RGB triplet in hexadecimal format.</p>
|
|||
|
<p>Not all terminals support this and, of those that do, not all
|
|||
|
provide facilities to test the support, hence the user should decide
|
|||
|
based on the terminal type. Most terminals support the colours
|
|||
|
<code>black</code>, <code>red</code>, <code>green</code>, <code>yellow</code>, <code>blue</code>, <code>magenta</code>, <code>cyan</code> and
|
|||
|
<code>white</code>, which can be set by name. In addition. <code>default</code> may be
|
|||
|
used to set the terminal’s default foreground colour. Abbreviations
|
|||
|
are allowed; <code>b</code> or <code>bl</code> selects black. Some terminals may generate
|
|||
|
additional colours if the <code>bold</code> attribute is also present.</p>
|
|||
|
<p>On recent terminals and on systems with an up-to-date terminal
|
|||
|
database the number of colours supported may be tested by the
|
|||
|
command ‘<code>echotc Co</code>’; if this succeeds, it indicates a limit on the
|
|||
|
number of colours which will be enforced by the line editor. The
|
|||
|
number of colours is in any case limited to 256 (i.e. the range 0 to
|
|||
|
255).</p>
|
|||
|
<p>Some modern terminal emulators have support for 24-bit true colour
|
|||
|
(16 million colours). In this case, the hex triplet format can be
|
|||
|
used. This consists of a ‘<code>#</code>’ followed by either a three or six
|
|||
|
digit hexadecimal number describing the red, green and blue
|
|||
|
components of the colour. Hex triplets can also be used with 88 and
|
|||
|
256 colour terminals via the <code>zsh/nearcolor</code> module (see <a href="Zsh-Modules.html#The-zsh_002fnearcolor-Module">The
|
|||
|
zsh/nearcolor
|
|||
|
Module</a>).</p>
|
|||
|
<p>Colour is also known as color.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>bg=``colour</code><br />
|
|||
|
The background colour should be set to <code>colour</code>. This works
|
|||
|
similarly to the foreground colour, except the background is not
|
|||
|
usually affected by the bold attribute.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>bold</code><br />
|
|||
|
The characters in the given context are shown in a bold font. Not
|
|||
|
all terminals distinguish bold fonts.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>standout</code><br />
|
|||
|
The characters in the given context are shown in the terminal’s
|
|||
|
standout mode. The actual effect is specific to the terminal; on
|
|||
|
many terminals it is inverse video. On some such terminals, where
|
|||
|
the cursor does not blink it appears with standout mode negated,
|
|||
|
making it less than clear where the cursor actually is. On such
|
|||
|
terminals one of the other effects may be preferable for
|
|||
|
highlighting the region and matched search string.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p><code>underline</code><br />
|
|||
|
The characters in the given context are shown underlined. Some
|
|||
|
terminals show the foreground in a different colour instead; in this
|
|||
|
case whitespace will not be highlighted.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>The characters described above as ‘special’ are as follows. The
|
|||
|
formatting described here is used irrespective of whether the characters
|
|||
|
are highlighted:</p>
|
|||
|
<ul>
|
|||
|
<li>
|
|||
|
<p>ASCII control characters<br />
|
|||
|
Control characters in the ASCII range are shown as ‘<code>^</code>’ followed by
|
|||
|
the base character.</p>
|
|||
|
<p>This item applies to control characters not in the ASCII range, plus
|
|||
|
other characters as follows. If the <code>MULTIBYTE</code> option is in effect,
|
|||
|
multibyte characters not in the ASCII character set that are
|
|||
|
reported as having zero width are treated as combining characters
|
|||
|
when the option <code>COMBINING_CHARS</code> is on. If the option is off, or if
|
|||
|
a character appears where a combining character is not valid, the
|
|||
|
character</p>
|
|||
|
<p>angle brackets. The number is the code point of the character in the
|
|||
|
wide character set; this may or may not be Unicode, depending on the
|
|||
|
operating system.</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>Invalid multibyte characters<br />
|
|||
|
If the <code>MULTIBYTE</code> option is in effect, any sequence of one or more
|
|||
|
bytes that does not form a valid character in the current character
|
|||
|
set is treated as a series of bytes each shown as a special
|
|||
|
character. as the bytes are represented as two hexadecimal digits
|
|||
|
between angle brackets, as distinct from the four or eight digits
|
|||
|
that are used for character set.</p>
|
|||
|
<p>Not all systems support this: for it to work, the system’s
|
|||
|
representation of wide characters must be code values from the
|
|||
|
Universal Character Set, as defined by IS0 10646 (also known as
|
|||
|
Unicode).</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>Wrapped double-width characters<br />
|
|||
|
When a double-width character appears in the final column of a line,
|
|||
|
it is instead shown on the next line. The empty space left in the
|
|||
|
original position is highlighted as a special character.</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
<p>If <code>zle_highlight</code> is not set or no value applies to a particular
|
|||
|
context, the defaults applied are equivalent to</p>
|
|||
|
<div class="example">
|
|||
|
<pre><code class="language-example">zle_highlight=(region:standout special:standout
|
|||
|
suffix:bold isearch:underline paste:standout)
|
|||
|
</code></pre>
|
|||
|
</div>
|
|||
|
<p>i.e. both the region and special characters are shown in standout mode.</p>
|
|||
|
<p>Within widgets, arbitrary regions may be highlighted by setting the
|
|||
|
special array parameter <code>region_highlight</code>; see <a href="#Zle-Widgets">Widgets</a>.</p>
|
|||
|
<hr />
|
|||
|
<p>This document was generated on <em>February 15, 2020</em> using
|
|||
|
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br />
|
|||
|
Zsh version 5.8, released on February 14, 2020.</p>
|
|||
|
|
|||
|
</main>
|
|||
|
|
|||
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|||
|
<!-- Mobile navigation buttons -->
|
|||
|
|
|||
|
<a rel="prev" href="Shell-Builtin-Commands.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|||
|
<i class="fa fa-angle-left"></i>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<a rel="next" href="Completion-Widgets.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|||
|
<i class="fa fa-angle-right"></i>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
<div style="clear: both"></div>
|
|||
|
</nav>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|||
|
|
|||
|
<a rel="prev" href="Shell-Builtin-Commands.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|||
|
<i class="fa fa-angle-left"></i>
|
|||
|
</a>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<a rel="next" href="Completion-Widgets.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|||
|
<i class="fa fa-angle-right"></i>
|
|||
|
</a>
|
|||
|
|
|||
|
</nav>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<!-- Livereload script (if served using the cli tool) -->
|
|||
|
<script type="text/javascript">
|
|||
|
var socket = new WebSocket("ws://localhost:3000/__livereload");
|
|||
|
socket.onmessage = function (event) {
|
|||
|
if (event.data === "reload") {
|
|||
|
socket.close();
|
|||
|
location.reload();
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
window.onbeforeunload = function() {
|
|||
|
socket.close();
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
window.playground_copyable = true;
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
|
|||
|
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
|
|||
|
<script src="searcher.js" type="text/javascript" charset="utf-8"></script>
|
|||
|
|
|||
|
|
|||
|
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
|
|||
|
<script src="highlight.js" type="text/javascript" charset="utf-8"></script>
|
|||
|
<script src="book.js" type="text/javascript" charset="utf-8"></script>
|
|||
|
|
|||
|
<!-- Custom JS scripts -->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|