How to draw a long bash command in vim?

A shell command can kill a chrome process.

ps -ef | grep chrome |awk '{print $2}'| xargs kill 

Now I want to match the character - with the bash command.

 nnoremap - :!ps -ef | grep chrome |awk '{print $2}'| xargs kill 

It doesn't matter how to display my bash command?

+7
vim shell call
source share
1 answer

Get out of the pipe

Each pipe must be shielded. Then add it using <CR> , so you don't have to press enter all the time.

 nnoremap - :!ps -ef \| grep chrome \|awk '{print $2}'\| xargs kill<CR> 

Kill'em all

Notice also that we have a cute little tool to kill everyone. Therefore, instead of

 ps -ef | grep chrome |awk '{print $2}'| xargs kill 

You can do

 killall chrome 

Then your mapping will be

 nnoremap - :!killall chrome<CR> 
+11
source share

All Articles