I forgot the array syntax while on Zsh-commandline:
$ hello=[1,2,3,4] %ERR:
I want to fix the problem开发者_开发问答 by substitution. In Vim, I would do :.s@,@ @g
.
So how can I edit the current line, or let call it a current buffer, by running a command on it?
[jkramer/sgi5k:~]# list=(1,2,3,4,5,6,7,8,9,10)
[jkramer/sgi5k:~]# !:gs/,/ /
list=(1 2 3 4 5 6 7 8 9 10)
See zshexpn(1) for more information of history completion/alternation.
Only using custom zle widget, for example:
function _-sedsubs()
{
emulate -LR zsh
local SEDARG="s"
zle -R "Substitution: $SEDARG"
local key=""
read -k key
local -r start=$key
while (( (#key)!=(##\n) &&
(#key)!=(##\r) )) ; do
if (( (#key)==(##^?) || (#key)==(##^h) )) ; then
SEDARG=${SEDARG[1,-2]}
else
SEDARG="${SEDARG}$key"
fi
zle -R "Substitution: $SEDARG"
read -k key || return 1
done
BUFFER="$(echo $BUFFER | sed -r -e "$SEDARG")"
}
zle -N sedsubstitute _-sedsubs
bindkey "\C-o:s" sedsubstitute
精彩评论