Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Bruno Heridet edited this pageSep 30, 2019 ·4 revisions

GNU Readline is a library that prints a prompt and waits for you to type something and press Enter. It's most famously used bybash for command-line editing, but is also used by many other programs likethe PostgreSQL command-line client andthe Python interactive interpreter. Readline (as you might expect, being a GNU project) defaults to and extensively supportsEmacs style keybindings, but also supports very extensive configuration for custom keybindings.

Note: If you want to use Real Kakoune to edit a command-line, you can bind a key toedit-and-execute-command (<c-x><c-e> in Emacs mode, not bound by default in Vi mode) which opens the current command in$EDITOR. Forbash specifically, there's also thefc command.

Because Kakoune's editing model is very different from the ones Readline was designed to support, it's not possible to implement it exactly. However, if you stick the following into~/.inputrc, you'll get something that feels at least a little familiar:

# Make Readline always default to vi-emulation, then we'll lay our Kakoune# bindings on top of that.set editing-mode viset keymap vi# Kakoune's unusual select-and-move editing model means that most Kakoune# keybindings correspond to a "select" and a "move" action in Readline terms.# However, Readline does not support binding a key to a sequence of actions,# only to a single action, or a sequence of other keys.# Therefore, we bind weird, unused key-sequences to the individual actions we# want to use, and make our Kakoune-style bindings invoke sequences of them.# I chose <c-a><c-x> as the common prefix, because Kakoune does not map them# to anything by default, let alone in sequence.# Weird unlikely-to-be-used mappings for the functions we want to use"\C-a\C-xm": set-mark"\C-a\C-xh": backward-char"\C-a\C-xl": forward-char"\C-a\C-xw": vi-forward-word"\C-a\C-xW": vi-forward-bigword"\C-a\C-xb": vi-backward-word"\C-a\C-xB": vi-backward-bigword"\C-a\C-xe": vi-end-word"\C-a\C-xE": vi-end-bigword"\C-a\C-xf": vi-char-search"\C-a\C-xt": vi-char-search"\C-a\C-xF": vi-char-search"\C-a\C-xT": vi-char-search"\C-a\C-x0": beginning-of-line"\C-a\C-x$": end-of-line"\C-a\C-xd": kill-region"\C-a\C-xy": copy-region-as-kill# Kakoune keybindings defined as concatenations of the above functions"h": "\C-a\C-xm\C-a\C-xh""H": "\C-a\C-xh""\M-h": "\C-a\C-xm\C-a\C-x0""\M-H": "\C-a\C-x0""gh": "\C-a\C-x0\C-a\C-xm""Gh": "\C-a\C-x0""GH": "\C-a\C-x0""l": "\C-a\C-xm\C-a\C-xl""L": "\C-a\C-xl""gl": "\C-a\C-x$\C-a\C-xm""Gl": "\C-a\C-x$""GL": "\C-a\C-x$""\M-l": "\C-a\C-xm\C-a\C-x$""\M-L": "\C-a\C-x$""w": "\C-a\C-xm\C-a\C-xw""W": "\C-a\C-xw""\M-w": "\C-a\C-xm\C-a\C-xW""\M-W": "\C-a\C-xW""b": "\C-a\C-xm\C-a\C-xb""B": "\C-a\C-xb""\M-b": "\C-a\C-xm\C-a\C-xB""\M-B": "\C-a\C-xB""e": "\C-a\C-xm\C-a\C-xe""E": "\C-a\C-xE""\M-e": "\C-a\C-xm\C-a\C-xE""\M-E": "\C-a\C-xE""f": "\C-a\C-xm\C-a\C-xf""F": "\C-a\C-xf""\M-f": "\C-a\C-xm\C-a\C-xF""\M-F": "\C-a\C-xF""t": "\C-a\C-xm\C-a\C-xt""T": "\C-a\C-xt""\M-t": "\C-a\C-xm\C-a\C-xT""\M-T": "\C-a\C-xT""x": "\C-a\C-x0\C-a\C-xm\C-a\C-x$"";": "\C-a\C-xm""\M-;": exchange-point-and-mark"d": kill-region"gg": beginning-of-history"gk": beginning-of-history"gj": end-of-history"ge": end-of-history "c": "\C-a\C-xdi""y": "\C-a\C-xy""P": "\C-a\C-xhp"

Known problems

  • We emulate Kakoune's selection system on top of Readline's Emacs-style regions. However, Emacs' convention is that the character under the cursor isnot part of the region, while Kakoune says that the character under the cursoris part of the selection. There's probably no good way around that.
  • Readline's standard vi keybindings mapf,t,F andT all to the same command,vi-char-search, which presumably decides what to do based on what key it was bound to. Surprisingly, Kakoune-styleF andT bindings work, but<a-f> and<a-t> bindings do not.
  • Readline does not highlight the "region", what Kakoune would call the "selection", making this even harder to use than the bugginess would suggest.

See what mode you are in

set show-mode-in-prompt onset vi-ins-mode-string \1\e[6 q\2set vi-cmd-mode-string \1\e[2 q\2

Fromhttps://stackoverflow.com/a/42107711/165544

Plugins

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp