I have a bash_file that operates on a latex file to produce a pdf.

/usr/bin/pandoc/ filein.md -t beamer -o fileout.md ;
/usr/bin/pdflatex/ fileother.tex ;
/usr/bin/evince fileother.tex

If I execute in normal mode

! ./bash_file.sh

it works fine but I cannnot work in vim while I am viewing the pdf

I want to be in vim normal mode and have a command, that executes the .sh without disturbing my current buffer (so that I can keep working on the tex file). I want something that should work similar to leader-ll leader-lv commands in the vim latex-suite template.

How should I do this? Thanks :)

2 Answers 2


If you start vim in a folder which contains the file foo.sh with the following content:


echo "Output of the bash script"

You can open a new buffer (:enew for example) and execute the script and get it's output in this new buffer with the following command:

:read ! ./foo.sh

Your new buffer will contain:

Output of the bash script

read executes a command and insert its standard output below the cursor and ! executes a command in the shell (here the command is ./foo.sh).

Of course if you use it often you can make it a command:

    command! MyCommand enew | read ! ./test.sh

Then :MyCommand will open the new buffer and read the output of your script into the new buffer.


  • This doesn't work for what I want to do :(. The last command on my bash file opens evince. read command indeed opens the pdf file but I cannot operate vim while evince is open. Moreover, when I close evince I get strange changes in the buffer that I execute the read command.
    – Hipparkhos
    Commented Jan 21, 2018 at 19:49
  • 2
    I can answer the second part of your question: launch evince as a sub-process from your shell command: evince your_file.pdf & or perhaps even evince your_file.pdf 2> /dev/null &. I would suggest editing your question with the steps that you took based on statox's answer, as well as showing an abbreviated version of your shell script. Commented Jan 21, 2018 at 20:15
  • Barton is right editing your question should help us to answer you. And they are also right with the background idea :)
    – statox
    Commented Jan 21, 2018 at 20:37
  • @BartonChittenden starting evince as a sub-process works fine :)
    – Hipparkhos
    Commented Jan 22, 2018 at 13:52

Before you execute your command, run


This will open a shell in a buffer window. You can then run commands there, and then while those commands are running ^W back to a normal window. This does, admittedly, make it a little annoying to send CTRL-W to that window; you need to press a period after your CTRL-W. You can get more help on various keys available there using

:help ctrl-w_.

You can run different things in the terminal window instead of your default shell, including the command you were wanting to run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.