ZSH: how can I run the Vim-style replacement command on the command line?

I forgot the array syntax in Zsh-commandline:

$ hello=[1,2,3,4] %ERR: 

I want to fix the problem by replacing. In Vim, I would do : .s@ ,@ @g . So, how can I edit the current line or give it a call to the current buffer by running a command on it?

+4
source share
2 answers
 [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 zhexpn (1) for more information on ending / interleaving a story.

+4
source

Only use custom zle widget, for example:

 function _-sedsubs() { emulate -LR zsh zle -R "Substitution:" local SEDARG="s" 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 "\Co:s" sedsubstitute 
+2
source

Source: https://habr.com/ru/post/1307058/


All Articles