mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
docs: standardise name for vi mode
Vi mode, vi-mode and various permutations are used. Standardise on "vi mode".
This commit is contained in:
parent
00ffc397b4
commit
ea256323ab
6 changed files with 20 additions and 20 deletions
|
@ -36,7 +36,7 @@ To find out what sequence a key combination sends, you can use :doc:`fish_key_re
|
||||||
|
|
||||||
If no ``SEQUENCE`` is provided, all bindings (or just the bindings in the given ``MODE``) are printed. If ``SEQUENCE`` is provided but no ``COMMAND``, just the binding matching that sequence is printed.
|
If no ``SEQUENCE`` is provided, all bindings (or just the bindings in the given ``MODE``) are printed. If ``SEQUENCE`` is provided but no ``COMMAND``, just the binding matching that sequence is printed.
|
||||||
|
|
||||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default". Every key binding applies to a single mode; you can specify which one with ``-M MODE``. If the key binding should change the mode, you can specify the new mode with ``-m NEW_MODE``. The mode can be viewed and changed via the ``$fish_bind_mode`` variable. If you want to change the mode from inside a fish function, use ``set fish_bind_mode MODE``.
|
Key bindings may use "modes", which mimics vi's modal input behavior. The default mode is "default". Every key binding applies to a single mode; you can specify which one with ``-M MODE``. If the key binding should change the mode, you can specify the new mode with ``-m NEW_MODE``. The mode can be viewed and changed via the ``$fish_bind_mode`` variable. If you want to change the mode from inside a fish function, use ``set fish_bind_mode MODE``.
|
||||||
|
|
||||||
To save custom key bindings, put the ``bind`` statements into :ref:`config.fish <configuration>`. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
To save custom key bindings, put the ``bind`` statements into :ref:`config.fish <configuration>`. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ The following special input functions are available:
|
||||||
reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility)
|
reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility)
|
||||||
|
|
||||||
``repaint-mode``
|
``repaint-mode``
|
||||||
reexecutes the :doc:`fish_mode_prompt <fish_mode_prompt>` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint.
|
reexecutes the :doc:`fish_mode_prompt <fish_mode_prompt>` and redraws the prompt. This is useful for vi mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint.
|
||||||
|
|
||||||
``self-insert``
|
``self-insert``
|
||||||
inserts the matching sequence into the command line
|
inserts the matching sequence into the command line
|
||||||
|
@ -346,7 +346,7 @@ Perform a history search when :kbd:`Page Up` is pressed::
|
||||||
|
|
||||||
bind -k ppage history-search-backward
|
bind -k ppage history-search-backward
|
||||||
|
|
||||||
Turn on :ref:`Vi key bindings <vi-mode>` and rebind :kbd:`Control`\ +\ :kbd:`C` to clear the input line::
|
Turn on :ref:`vi key bindings <vi-mode>` and rebind :kbd:`Control`\ +\ :kbd:`C` to clear the input line::
|
||||||
|
|
||||||
set -g fish_key_bindings fish_vi_key_bindings
|
set -g fish_key_bindings fish_vi_key_bindings
|
||||||
bind -M insert \cc kill-whole-line repaint
|
bind -M insert \cc kill-whole-line repaint
|
||||||
|
|
|
@ -20,11 +20,11 @@ Synopsis
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
The ``fish_mode_prompt`` function outputs the mode indicator for use in vi-mode.
|
The ``fish_mode_prompt`` function outputs the mode indicator for use in vi mode.
|
||||||
|
|
||||||
The default ``fish_mode_prompt`` function will output indicators about the current Vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. The ``$fish_bind_mode variable`` can be used to determine the current mode. It will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
|
The default ``fish_mode_prompt`` function will output indicators about the current vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. The ``$fish_bind_mode variable`` can be used to determine the current mode. It will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
|
||||||
|
|
||||||
You can also define an empty ``fish_mode_prompt`` function to remove the Vi mode indicators::
|
You can also define an empty ``fish_mode_prompt`` function to remove the vi mode indicators::
|
||||||
|
|
||||||
function fish_mode_prompt; end
|
function fish_mode_prompt; end
|
||||||
funcsave fish_mode_prompt
|
funcsave fish_mode_prompt
|
||||||
|
|
|
@ -24,7 +24,7 @@ The following parameters are available:
|
||||||
**--no-erase**
|
**--no-erase**
|
||||||
Does not clear previous set bindings
|
Does not clear previous set bindings
|
||||||
|
|
||||||
Further information on how to use :ref:`vi-mode <vi-mode>`.
|
Further information on how to use :ref:`vi mode <vi-mode>`.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -299,7 +299,7 @@ Both ``*`` and ``x`` are valid ways to spell multiplication, but ``*`` needs to
|
||||||
Prompts
|
Prompts
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Fish does not use the ``$PS1``, ``$PS2`` and so on variables. Instead the prompt is the output of the :doc:`fish_prompt <cmds/fish_prompt>` function, plus the :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` function if vi-mode is enabled and the :doc:`fish_right_prompt <cmds/fish_right_prompt>` function for the right prompt.
|
Fish does not use the ``$PS1``, ``$PS2`` and so on variables. Instead the prompt is the output of the :doc:`fish_prompt <cmds/fish_prompt>` function, plus the :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` function if :ref:`vi mode <vi-mode>` is enabled. The output of the :doc:`fish_right_prompt <cmds/fish_right_prompt>` function is used for the right-sided prompt.
|
||||||
|
|
||||||
As an example, here's a relatively simple bash prompt:
|
As an example, here's a relatively simple bash prompt:
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ Tab Completion
|
||||||
|
|
||||||
Tab completion is a time saving feature of any modern shell. When you type :kbd:`Tab`, fish tries to guess the rest of the word under the cursor. If it finds just one possibility, it inserts it. If it finds more, it inserts the longest unambiguous part and then opens a menu (the "pager") that you can navigate to find what you're looking for.
|
Tab completion is a time saving feature of any modern shell. When you type :kbd:`Tab`, fish tries to guess the rest of the word under the cursor. If it finds just one possibility, it inserts it. If it finds more, it inserts the longest unambiguous part and then opens a menu (the "pager") that you can navigate to find what you're looking for.
|
||||||
|
|
||||||
The pager can be navigated with the arrow keys, :kbd:`Page Up` / :kbd:`Page Down`, :kbd:`Tab` or :kbd:`Shift`\ +\ :kbd:`Tab`. Pressing :kbd:`Control`\ +\ :kbd:`S` (the ``pager-toggle-search`` binding - :kbd:`/` in vi-mode) opens up a search menu that you can use to filter the list.
|
The pager can be navigated with the arrow keys, :kbd:`Page Up` / :kbd:`Page Down`, :kbd:`Tab` or :kbd:`Shift`\ +\ :kbd:`Tab`. Pressing :kbd:`Control`\ +\ :kbd:`S` (the ``pager-toggle-search`` binding - :kbd:`/` in vi mode) opens up a search menu that you can use to filter the list.
|
||||||
|
|
||||||
Fish provides some general purpose completions, like for commands, variable names, usernames or files.
|
Fish provides some general purpose completions, like for commands, variable names, usernames or files.
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ When it is fish's turn to ask for input (like after it started or the command en
|
||||||
This prompt is determined by running the :doc:`fish_prompt <cmds/fish_prompt>` and :doc:`fish_right_prompt <cmds/fish_right_prompt>` functions.
|
This prompt is determined by running the :doc:`fish_prompt <cmds/fish_prompt>` and :doc:`fish_right_prompt <cmds/fish_right_prompt>` functions.
|
||||||
|
|
||||||
The output of the former is displayed on the left and the latter's output on the right side of the terminal.
|
The output of the former is displayed on the left and the latter's output on the right side of the terminal.
|
||||||
For :ref:`vi-mode <vi-mode>`, the output of :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` will be prepended on the left.
|
For :ref:`vi mode <vi-mode>`, the output of :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` will be prepended on the left.
|
||||||
|
|
||||||
Fish ships with a few prompts which you can see with :doc:`fish_config <cmds/fish_config>`. If you run just ``fish_config`` it will open a web interface [#]_ where you'll be shown the prompts and can pick which one you want. ``fish_config prompt show`` will show you the prompts right in your terminal.
|
Fish ships with a few prompts which you can see with :doc:`fish_config <cmds/fish_config>`. If you run just ``fish_config`` it will open a web interface [#]_ where you'll be shown the prompts and can pick which one you want. ``fish_config prompt show`` will show you the prompts right in your terminal.
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ Command line editor
|
||||||
|
|
||||||
The fish editor features copy and paste, a :ref:`searchable history <history-search>` and many editor functions that can be bound to special keyboard shortcuts.
|
The fish editor features copy and paste, a :ref:`searchable history <history-search>` and many editor functions that can be bound to special keyboard shortcuts.
|
||||||
|
|
||||||
Like bash and other shells, fish includes two sets of keyboard shortcuts (or key bindings): one inspired by the Emacs text editor, and one by the Vi text editor. The default editing mode is Emacs. You can switch to Vi mode by running :doc:`fish_vi_key_bindings <cmds/fish_vi_key_bindings>` and switch back with :doc:`fish_default_key_bindings <cmds/fish_default_key_bindings>`. You can also make your own key bindings by creating a function and setting the ``fish_key_bindings`` variable to its name. For example::
|
Like bash and other shells, fish includes two sets of keyboard shortcuts (or key bindings): one inspired by the Emacs text editor, and one by the vi text editor. The default editing mode is Emacs. You can switch to vi mode by running :doc:`fish_vi_key_bindings <cmds/fish_vi_key_bindings>` and switch back with :doc:`fish_default_key_bindings <cmds/fish_default_key_bindings>`. You can also make your own key bindings by creating a function and setting the ``fish_key_bindings`` variable to its name. For example::
|
||||||
|
|
||||||
|
|
||||||
function fish_hybrid_key_bindings --description \
|
function fish_hybrid_key_bindings --description \
|
||||||
|
@ -293,7 +293,7 @@ While the key bindings included with fish include many of the shortcuts popular
|
||||||
Shared bindings
|
Shared bindings
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Some bindings are common across Emacs and Vi mode, because they aren't text editing bindings, or because what Vi/Vim does for a particular key doesn't make sense for a shell.
|
Some bindings are common across Emacs and vi mode, because they aren't text editing bindings, or because what vi/Vim does for a particular key doesn't make sense for a shell.
|
||||||
|
|
||||||
- :kbd:`Tab` :ref:`completes <tab-completion>` the current token. :kbd:`Shift`\ +\ :kbd:`Tab` completes the current token and starts the pager's search mode. :kbd:`Tab` is the same as :kbd:`Control`\ +\ :kbd:`I`.
|
- :kbd:`Tab` :ref:`completes <tab-completion>` the current token. :kbd:`Shift`\ +\ :kbd:`Tab` completes the current token and starts the pager's search mode. :kbd:`Tab` is the same as :kbd:`Control`\ +\ :kbd:`I`.
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ Some bindings are common across Emacs and Vi mode, because they aren't text edit
|
||||||
|
|
||||||
- :kbd:`Alt`\ +\ :kbd:`S` Prepends ``sudo`` to the current commandline. If the commandline is empty, prepend ``sudo`` to the last commandline.
|
- :kbd:`Alt`\ +\ :kbd:`S` Prepends ``sudo`` to the current commandline. If the commandline is empty, prepend ``sudo`` to the last commandline.
|
||||||
|
|
||||||
- :kbd:`Control`\ +\ :kbd:`Space` Inserts a space without expanding an :ref:`abbreviation <abbreviations>`. For vi-mode this only applies to insert-mode.
|
- :kbd:`Control`\ +\ :kbd:`Space` Inserts a space without expanding an :ref:`abbreviation <abbreviations>`. For vi mode, this only applies to insert-mode.
|
||||||
|
|
||||||
.. _emacs-mode:
|
.. _emacs-mode:
|
||||||
|
|
||||||
|
@ -393,10 +393,10 @@ You can change these key bindings using the :doc:`bind <cmds/bind>` builtin.
|
||||||
Vi mode commands
|
Vi mode commands
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Vi mode allows for the use of Vi-like commands at the prompt. Initially, :ref:`insert mode <vi-mode-insert>` is active. :kbd:`Escape` enters :ref:`command mode <vi-mode-command>`. The commands available in command, insert and visual mode are described below. Vi mode shares :ref:`some bindings <shared-binds>` with :ref:`Emacs mode <emacs-mode>`.
|
Vi mode allows for the use of vi-like commands at the prompt. Initially, :ref:`insert mode <vi-mode-insert>` is active. :kbd:`Escape` enters :ref:`command mode <vi-mode-command>`. The commands available in command, insert and visual mode are described below. Vi mode shares :ref:`some bindings <shared-binds>` with :ref:`Emacs mode <emacs-mode>`.
|
||||||
|
|
||||||
To enable vi mode, use :doc:`fish_vi_key_bindings <cmds/fish_vi_key_bindings>`.
|
To enable vi mode, use :doc:`fish_vi_key_bindings <cmds/fish_vi_key_bindings>`.
|
||||||
It is also possible to add all emacs-mode bindings to vi-mode by using something like::
|
It is also possible to add all Emacs mode bindings to vi mode by using something like::
|
||||||
|
|
||||||
|
|
||||||
function fish_user_key_bindings
|
function fish_user_key_bindings
|
||||||
|
@ -411,11 +411,11 @@ It is also possible to add all emacs-mode bindings to vi-mode by using something
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
When in vi-mode, the :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` function will display a mode indicator to the left of the prompt. To disable this feature, override it with an empty function. To display the mode elsewhere (like in your right prompt), use the output of the ``fish_default_mode_prompt`` function.
|
When in vi mode, the :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` function will display a mode indicator to the left of the prompt. To disable this feature, override it with an empty function. To display the mode elsewhere (like in your right prompt), use the output of the ``fish_default_mode_prompt`` function.
|
||||||
|
|
||||||
When a binding switches the mode, it will repaint the mode-prompt if it exists, and the rest of the prompt only if it doesn't. So if you want a mode-indicator in your ``fish_prompt``, you need to erase ``fish_mode_prompt`` e.g. by adding an empty file at ``~/.config/fish/functions/fish_mode_prompt.fish``. (Bindings that change the mode are supposed to call the `repaint-mode` bind function, see :doc:`bind <cmds/bind>`)
|
When a binding switches the mode, it will repaint the mode-prompt if it exists, and the rest of the prompt only if it doesn't. So if you want a mode-indicator in your ``fish_prompt``, you need to erase ``fish_mode_prompt`` e.g. by adding an empty file at ``~/.config/fish/functions/fish_mode_prompt.fish``. (Bindings that change the mode are supposed to call the `repaint-mode` bind function, see :doc:`bind <cmds/bind>`)
|
||||||
|
|
||||||
The ``fish_vi_cursor`` function will be used to change the cursor's shape depending on the mode in supported terminals. The following snippet can be used to manually configure cursors after enabling vi-mode::
|
The ``fish_vi_cursor`` function will be used to change the cursor's shape depending on the mode in supported terminals. The following snippet can be used to manually configure cursors after enabling vi mode::
|
||||||
|
|
||||||
# Emulates vim's cursor shape behavior
|
# Emulates vim's cursor shape behavior
|
||||||
# Set the normal and visual mode cursors to a block
|
# Set the normal and visual mode cursors to a block
|
||||||
|
@ -576,7 +576,7 @@ If you want to be able to press :kbd:`Escape` and then a character and have it c
|
||||||
|
|
||||||
Similarly, to disambiguate *other* keypresses where you've bound a subsequence and a longer sequence, fish has :envvar:`fish_sequence_key_delay_ms`::
|
Similarly, to disambiguate *other* keypresses where you've bound a subsequence and a longer sequence, fish has :envvar:`fish_sequence_key_delay_ms`::
|
||||||
|
|
||||||
# This binds "jk" to switch to normal mode in vi-mode.
|
# This binds "jk" to switch to normal mode in vi mode.
|
||||||
# If you kept it like that, every time you press "j",
|
# If you kept it like that, every time you press "j",
|
||||||
# fish would wait for a "k" or other key to disambiguate
|
# fish would wait for a "k" or other key to disambiguate
|
||||||
bind -M insert -m default jk cancel repaint-mode
|
bind -M insert -m default jk cancel repaint-mode
|
||||||
|
|
|
@ -15,7 +15,7 @@ Unlike other shells, fish's prompt is built by running a function - :doc:`fish_p
|
||||||
|
|
||||||
- :doc:`fish_prompt <cmds/fish_prompt>`, which is the main prompt function
|
- :doc:`fish_prompt <cmds/fish_prompt>`, which is the main prompt function
|
||||||
- :doc:`fish_right_prompt <cmds/fish_right_prompt>`, which is shown on the right side of the terminal.
|
- :doc:`fish_right_prompt <cmds/fish_right_prompt>`, which is shown on the right side of the terminal.
|
||||||
- :doc:`fish_mode_prompt <cmds/fish_mode_prompt>`, which is shown if :ref:`vi-mode <vi-mode>` is used.
|
- :doc:`fish_mode_prompt <cmds/fish_mode_prompt>`, which is shown if :ref:`vi mode <vi-mode>` is used.
|
||||||
|
|
||||||
These functions are run, and whatever they print is displayed as the prompt (minus one trailing newline).
|
These functions are run, and whatever they print is displayed as the prompt (minus one trailing newline).
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ We have now built a simple but working and usable prompt, but of course more can
|
||||||
- ``prompt_login`` to describe the user/hostname/container or ``prompt_hostname`` to describe just the host
|
- ``prompt_login`` to describe the user/hostname/container or ``prompt_hostname`` to describe just the host
|
||||||
- ``fish_is_root_user`` to help with changing the symbol for root.
|
- ``fish_is_root_user`` to help with changing the symbol for root.
|
||||||
- ``fish_vcs_prompt`` to show version control information (or ``fish_git_prompt`` / ``fish_hg_prompt`` / ``fish_svn_prompt`` to limit it to specific systems)
|
- ``fish_vcs_prompt`` to show version control information (or ``fish_git_prompt`` / ``fish_hg_prompt`` / ``fish_svn_prompt`` to limit it to specific systems)
|
||||||
- You can add a right prompt by changing :doc:`fish_right_prompt <cmds/fish_right_prompt>` or a vi-mode prompt by changing :doc:`fish_mode_prompt <cmds/fish_mode_prompt>`.
|
- You can add a right prompt by changing :doc:`fish_right_prompt <cmds/fish_right_prompt>` or a vi mode prompt by changing :doc:`fish_mode_prompt <cmds/fish_mode_prompt>`.
|
||||||
- Some prompts have interesting or advanced features
|
- Some prompts have interesting or advanced features
|
||||||
- Add the time when the prompt was printed
|
- Add the time when the prompt was printed
|
||||||
- Show various integrations like python's venv
|
- Show various integrations like python's venv
|
||||||
|
|
Loading…
Reference in a new issue