I can reproduce this issue on cygwin and Ubuntu wsl's oh-my-zsh shell, but my bash shell works the way I want. My intent is to run these two lines on the command line:
npm rm plugin-alias
npm i -D plugin-alias
Here are a series of commands I typed into zsh in an attempt to achieve that:
$ npm rm plugin-alias
$ ^rm^i # when I pressed space, it auto completed to:
npm i plugin-alias # and my cursor was placed at the end of the line.
# I `ctrl+c`'d to try other ideas
$ ^rm^'i\ # when I pressed space...
npm i plugin-alias # this auto completed the same as above.
# I `ctrl+c`'d to try other ideas
$ ^rm^'i -D'
npm 'i -D' plugin-alias # this auto completed to surround the argument in single quotes. Same issue with double quotes.
I tried some other Event Designators like !!s:/rm/i -D/..., but it auto expanded the same way. This leads me to believe there is a oh-my-zsh setting doing this. If I'm right about that, what's it called and how do I turn it off? I'd be okay with tab behaving this way, but not spaces.