Working with regions
Continuing the legacy of Emacs' inherited behavior, you can set regions in the command line by holding Ctrl and pressing the Space bar. This will trigger a region selection mechanism that you can expand with the arrow keys, which works just as if you were clicking and dragging your mouse to highlight text.
So, why bother with regions? You could, for example, mark a region via the Ctrl + Space bar sequence and then perform a command on top of it (similar to capitalize-word
we saw earlier), or even mix-in the previously mentioned execute-command
to call a function that has no keybind. Overall, these few niceties straight from Emacs give ZLE (and of course, zsh) the versatility to behave almost like a full-fledged editor.
Multiline ...
Get Learning Shell Scripting with Zsh now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.