Search code examples
vimbufferzsh

ZSH: how can I run Vim-style substitute command in command line?


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?


Solution

  • [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.