1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 17:24:50 +01:00

47306: edit-command-line: add editor style

This commit is contained in:
Mikael Magnusson 2020-08-05 16:47:45 +02:00
parent d877073959
commit 841188439b
3 changed files with 13 additions and 2 deletions

View file

@ -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:

View file

@ -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))(

View file

@ -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;;