Question: I have a bash\_file that operates on a latex file to produce a pdf.

```
#!/bin/bash
/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 :)

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

```
#!/bin/bash

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.

See

* [`:h :read`](http://vimhelp.appspot.com/insert.txt.html#%3aread)
* [`:h :!`](http://vimhelp.appspot.com/various.txt.html#%3a%21)
Before you execute your command, run

```
:term

```

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.