Unable to have Bash-like C-x-e in Zsh
Asked Answered
E

2

40

I found the following command in Bash which Zsh does not have in the same buttons at the thread.

Ctrl-x-e

It opens the current input in terminal to an editor.

How can you have the same command in Zsh?

Enphytotic answered 20/5, 2009 at 22:45 Comment(0)
M
51

I'm using it with VIM mode. Basically ESC-v (or simply v if already in command mode) opens the terminal. It is setup by:

autoload -U edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line

Here is how to setup it in emacs mode:

autoload edit-command-line
zle -N edit-command-line
bindkey '^Xe' edit-command-line

Use 'bindkey -e’ to to enable emacs style or ‘bindkey -v’ to enable vi style.

Melt answered 24/5, 2009 at 15:15 Comment(5)
Is the command for Emacs mode Ctrl-X-e? It did not work for me in terminal.Hemoglobin
It's Ctr-x, then e. You could change '^Xe' to '^X^e' if it is Ctrl-x ctrl-e what you want. Be sure to turn on emacs style (although it is the zsh default) by simply: bindkey -e alone in a line.Melt
@emg-2: It works. Thank you! I had a corrupted shell script which Zsh did not give any alert. I get an alert about it in Bash.Hemoglobin
What do the first 2 lines do? Can I get away with just setting bindkey -M vicmd v edit-command-line with my other bindkeys?Rhines
This is absolutely delicious! Thank you for teaching my zsh how to do what I missed most from my stock bash days.Attainture
C
0

If you are using Sublime as your editor then make sure you have -w option added in .zshrc or .bashrc file, otherwise it may won't work.

export EDITOR='subl -w'
Chung answered 13/11, 2022 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.