Quantcast
Channel: How to execute selected lines in bash and print the output in the next line? - Vi and Vim Stack Exchange
Viewing all articles
Browse latest Browse all 3

How to execute selected lines in bash and print the output in the next line?

$
0
0

I know that with this command:

:yyp!!bash

I can execute current line and print the output in the next line (actually it copies the current line to the next line, executes it, and replaces it with the output), to get from this:

echo "Hello"

to this (after the command above):

echo "Hello"Hello

I also know that I can use this command:

:w !bash

To execute the selected lines (plural) and show the output in the window below the editor.

What I want is to be able to select multiple lines, execute it in bash, and print the output in vim. How can I do that?

So desired behavior is to get from:

echo \    -e "Hello\nWorld"echo "Hi"

to:

echo \    -e "Hello\nWorld"echo "Hi"HelloWorldHi

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images