I like to execute my scripts in the shell using
:! %
But once I do, I can't select the text from the shell in the output. I'm currently using neovim. When I click into the shell to select the text, I exit the shell. How can I get around this?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityThe %
in ! %
is a shortcut for the name of your current file, not the contents of the file.
If I name a file ls and open it in vim and run ! %
the output of the ls command will be shown.
! %
. There are a couple ways to do this: 1. You can pipe the output of the command through xclip to copy it, and then simply paste it into a new vim buffer. 2. Another solution is to pipe the output of the command to vim with [command] | vim -
to do some work there before copying/saving the output och parts of the output. 3. :%![command]
to run the current file through the command and view the output in current buffer.
Dec 30, 2022 at 13:47
Usually for this kind of stuff I use the vim function read
:read! ls
or
:read! date
It will print the output/results inside the current buffer
If the shell interaction needs a but more interaction, I do things in the shell, pipe to files, and use command line tool xclip
for moving around the intersting stuffs from places to places as well inside as oustide vim
:terminal %
insteadr! %
to load the op in buffer, do what you want with it and then pressu
to undo