diff options
-rw-r--r-- | Completion/Zsh/Command/_zstyle | 1 | ||||
-rw-r--r-- | Doc/Zsh/contrib.yo | 6 | ||||
-rw-r--r-- | Functions/Zle/edit-command-line | 8 |
3 files changed, 13 insertions, 2 deletions
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle index e9a5d800c..bb871762e 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -143,6 +143,7 @@ styles=( cursor e: edit-buffer e:bool edit-previous e:bool + editor e: insert-kept e: leave-cursor e:bool match e: diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 66e6bdc1e..bab1e3023 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2472,6 +2472,12 @@ item(tt(edit-command-line))( Edit the command line using your visual editor, as in tt(ksh). example(bindkey -M vicmd v edit-command-line) + +The editor to be used can also be specified using the tt(editor) style in +the context of the widget. It is specified as an array of command and +arguments: + +example(zstyle :zle:edit-command-line editor gvim -f) ) tindex(expand-absolute-path) item(tt(expand-absolute-path))( diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line index 1103ca556..8aaeb738e 100644 --- a/Functions/Zle/edit-command-line +++ b/Functions/Zle/edit-command-line @@ -22,8 +22,12 @@ fi (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2] # Open the editor, placing the cursor at the right place if we know how. - local editor=( "${(@Q)${(z)${VISUAL:-${EDITOR:-vi}}}}" ) - case $editor in + local -a editor + zstyle -a :zle:$WIDGET editor editor + if (( ! $#editor )); then + editor=( "${(@Q)${(z)${VISUAL:-${EDITOR:-vi}}}}" ) + fi + case $editor in (*vim*) integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 )) "${(@)editor}" -c "normal! ${byteoffset}go" -- $1;; |