Dietline
Radare2 comes with the lean readline-like input capability through the lean library to handle the command edition and history navigation. It allows users to perform cursor movements, search the history, and implements autocompletion. Moreover, due to the radare2 portability, dietline provides the uniform experience among all supported platforms. It is used in all radare2 subshells - main prompt, SDB shell, visual prompt, and offsets prompt. It also implements the most common features and keybindings compatible with the GNU Readline.
Dietline supports two major configuration modes : Emacs-mode and Vi-mode.
It also supports the famous Ctrl-R
reverse history search. Using TAB
key it allows to scroll through the
autocompletion options.
Autocompletion
In the every shell and radare2 command autocompletion is supported. There are multiple modes of it -
files, flags, and SDB keys/namespaces. To provide the easy way to select possible completion options
the scrollable popup widget is available. It can be enabled with scr.prompt.popup
, just set it to
the true
.
Emacs (default) mode
By default dietline mode is compatible with readline Emacs-like mode key bindings. Thus active are:
Moving
Ctrl-a
- move to the beginning of the lineCtrl-e
- move to the end of the lineCtrl-b
- move one character backwardCtrl-f
- move one character forward
Deleting
Ctrl-w
- delete the previous wordCtrl-u
- delete the whole lineCtrl-h
- delete a character to the leftCtrl-d
- delete a character to the rightAlt-d
- cuts the character after the cursor
Killing and Yanking
Ctrl-k
- kill the text from point to the end of the line.Ctrl-x
- kill backward from the cursor to the beginning of the current line.Ctrl-t
- kill from point to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as forward-word.Ctrl-w
- kill the word behind point, using white space as a word boundary. The killed text is saved on the kill-ring.Ctrl-y
- yank the top of the kill ring into the buffer at point.Ctrl-]
- rotate the kill-ring, and yank the new top. You can only do this if the prior command is yank or yank-pop.
History
Ctrl-r
- the reverse search in the command history
Vi mode
Radare2 also comes with in vi mode that can be enabled by toggling scr.prompt.vi
. The various keybindings available in this mode are:
Entering command modes
ESC
- enter into the control modei
- enter into the insert mode
Moving
j
- acts like up arrow keyk
- acts like down arrow keya
- move cursor forward and enter into insert modeI
- move to the beginning of the line and enter into insert modeA
- move to the end of the line and enter into insert mode^
- move to the beginning of the line0
- move to the beginning of the line$
- move to the end of the lineh
- move one character backwardl
- move one character forwardb
- move cursor to the beginning of the current word, of if between word boundaries, to the beginning of the previous word.B
- same asb
, but only counting white-space as word boundarye
- move cursor the end of the current word, or if between boundaries, to the end of the next wordE
- same ase
, but only counting white-space as word boundaryw
- move cursor to the beginning of the next wordW
- same asw
, but only counting white-space as word boundaryf<char>
- move cursor forward to the first<char>
found. For examplefj
will move the cursor to the firstj
character found (if it found one)F<char>
- same asf<char>
, but search backwardst<char>
- same asf<char>
but stop before<char>
. For exampletj
will move the cursor forward to the character just beforej
T<char>
- same ast<char>
, but search backwards
Deleting and Yanking
x
- cuts the characterdw
- delete the current word from the current positiondiw
- delete inside the current worddb
- delete the previous wordD
- delete from the current cursor position to the end of lineC
- same asD
, but enter insert mode afterdd
- delete the whole line (from any position)cc
- same asdd
, but enter insert mode afterdh
- delete a character to the leftdl
- delete a character to the rightd$
- same asD
d^
- delete from the current cursor position to the beginning of linede
- kill from point to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as forward-word.df<char>
- delete from current position to the position of the first<char>
encountereddF<char>
- same asdf<char>
, but delete backwardsdt<char>
- delete from current position to the position of the character right before the first<char>
encountereddT<char>
- same asdt<char>
, but delete backwardsdi"
- delete everything between two"
charactersdi'
- delete everything between two'
charactersdi(
- delete everything between(
and)
charactersdi[
- delete everything between[
and]
charactersdi{
- delete everything between{
and}
charactersdi<
- delete everything between<
and>
charactersp
- yank the top of the kill ring into the buffer at point.c
- alld
commands have theirc
counterpart which enters insert mode after deleting
Other
~
- swap the case of the current character and move one character forward
If you are finding it hard to keep track of which mode you are in, just set scr.prompt.mode=true
to update the color of the prompt based on the vi-mode.