Skip to content

Commit eb9f868

Browse files
committed
executioner.vim 1.3.0
Add input and output redirection support Add :ExecutionerHorizontalBuffer and :ExecutionerVerticalBuffer Add java to defaults
1 parent 73bdcc3 commit eb9f868

File tree

3 files changed

+322
-197
lines changed

3 files changed

+322
-197
lines changed

README.md

Lines changed: 93 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# :sunrise_over_mountains: vim-executioner
22

3-
This plugin allows you to easily execute files in the terminal or a separate
3+
This plugin allows you to execute files in a terminal window or a separate
44
buffer.
55

66
![](https://raw.githubusercontent.com/wiki/EvanQuan/vim-executioner/executioner.PNG)
@@ -55,41 +55,110 @@ git clone https://github.com/EvanQuan/vim-executioner.git ~/.vim/bundle/vim-exec
5555

5656
#### Commands
5757

58-
This package comes with 3 commands:
58+
This plugin comes with 5 commands:
5959

60-
- `:Executioner`
61-
- `:ExecutionerHorizontal`
62-
- `:ExecutionerVertical`
63-
64-
Each command takes the name of a file as an 1 optional argument, optionally
60+
Each command takes the name of a file as an optional argument, optionally
6561
followed by any command-line arguments. Without any arguments, the current
6662
buffer that is executing the command will be ran with no arguments.
6763

64+
##### :Executioner
65+
66+
The file will be executed in a shell, where any output will be printed there.
6867
For example:
6968
```
7069
:Executioner
7170
```
72-
will attempt to execute the current buffer.
71+
will attempt to execute the current buffer with no command-line arguments.
7372
```
7473
:Executioner test.py
7574
```
76-
will attempt to execute `test.py` in the current working directory.
75+
will attempt to execute `test.py` in the current working directory with no
76+
command-line arguments.
7777
```
7878
:Executioner test.py foo bar 4
7979
```
8080
will attempt to execute `test.py` in the current working directory, with the
81-
arguments `foo`, `bar` and `4`.
81+
command-line arguments `foo`, `bar` and `4`.
82+
83+
##### :ExecutionerHorizontal
84+
85+
If Vim has `terminal` window support, then the file will be executed in
86+
a horizontally-split terminal window. Once the program execution is completed,
87+
the output will be saved in a 'readonly' buffer.
88+
89+
Otherwise, the file will be executed in a shell and its output will be saved
90+
in a horizontally-split 'readonly' buffer. The difference is that without
91+
|terminal| support, no input from the user can be made during the program's
92+
runtime.
93+
94+
##### :ExecutionerHorizontalBuffer
95+
96+
Same as `:ExecutionerHorizontal` with no |terminal| window support, forcing
97+
a shell to execute the file and save the output in a horizontally-split
98+
'readonly' buffer.
99+
100+
##### :ExecutionerVertical
101+
102+
If Vim has `terminal` window support, then the file will be executed in
103+
a vertically-split terminal window. Once the program execution is completed,
104+
the output will be saved in a 'readonly' buffer.
105+
106+
Otherwise, the file will be executed in a shell and its output will be saved
107+
in a vertically-split 'readonly' buffer. The difference is that without
108+
`terminal` support, no input from the user can be made during the program's
109+
runtime.
110+
111+
##### :ExecutionerVerticalBuffer
112+
113+
Same as `:ExecutionerVertical` with no `terminal` window support, forcing
114+
a shell to execute the file and save the output in a vertically-split
115+
'readonly' buffer.
82116

83-
If you running a version of Vim that has the integrated terminal feature (i.e.
84-
`:echo has("terminal")` returns 1), then the horizontal and vertical commands
85-
open a terminal buffer to output the command, allowing for potential user
86-
input.
117+
#### Terminal Window vs. Buffer
118+
119+
There are advantages and disadvantages to using either the terminal or buffer
120+
for split window execution. Perhaps some day in the future this distinction
121+
will no longer exist and there will be a unified solution.
122+
123+
| | Terminal | Buffer |
124+
|:----:|:--------:|:------:|
125+
| Pros | - Accepts standard input from user <br> - Prints standard output during program execution | - Can execute multiple commands directly <br> - Accepts standard input and output redirection |
126+
| Cons | - Cannot execute multiple commands directly <br> - Does not accept standard input and output redirection | - Does not accept standard input from user <br> - Prints standard output after program execution is complete |
127+
128+
##### Standard Input and Standard Output
129+
130+
If you running a version of Vim that has terminal window support, (i.e. `:echo
131+
has("terminal")` returns `1`), then the horizontal and vertical commands open
132+
an interactive terminal window which updates live as the program is being
133+
executed. This allows for user input from standard input, and displaying of
134+
standard output as it is being printed.
87135

88136
Without the terminal feature available, the horizontal and vertical commands
89-
stores the output of the executed program in a read-only buffer. Due to this
90-
reason, it will not work for programs that require user input.
137+
run the program until completion, and store the standard output of the
138+
executed program in a read-only buffer. Due to this reason, it will not work
139+
for programs that require user input and will not update the standard output
140+
over the course of the program execution.
141+
142+
##### Multiple Commands
143+
144+
Certain file types that involve multiple commands to be executed, such as
145+
compiling before executing, do not work with terminal windows. This is because
146+
terminal windows treat every space-separated term after the first argument as
147+
command-line arguments, including ones that end with `;`.
91148

92-
#### Key mappings
149+
Any terminal window command that involves multiple commands will fall back to
150+
the buffer equivalent if multiple commands are found.
151+
152+
##### Input and Output Redirection
153+
154+
For the same reason as multiple commands, terminal windows treat every
155+
space-separated term after the first argument as a command-line argument,
156+
including `>`, `<`, and `|` characters.
157+
158+
Any terminal window command that involves input redirection will fall back to
159+
the buffer equivalent if input redirection operators are found.
160+
161+
#### Key Mappings
93162

94163
By default, Executioner does not provide any key mappings as to not override
95164
mappings defined in your `vimrc`. You can map these commands to however you
@@ -104,6 +173,12 @@ nnoremap <silent> <leader>rf :Executioner<Return>
104173
nnoremap <silent> <leader>hrf :ExecutionerHorizontal<Return>
105174
nnoremap <silent> <leader>vrf :ExecutionerVertical<Return>
106175
176+
" Run current buffer with input redirected from input.txt
177+
"
178+
nnoremap <silent> <leader>ri :ExecutionerBuffer % < input.txt<Return>
179+
nnoremap <silent> <leader>hri :ExecutionerHorizontalBuffer % < input.txt<Return>
180+
nnoremap <silent> <leader>vri :ExecutionerVerticalBuffer % < input.txt<Return>
181+
107182
" run.sh
108183
"
109184
nnoremap <silent> <leader>rr :Executioner run.sh<Return>
@@ -183,6 +258,7 @@ yourself. These are the defaults:
183258
| c | gcc % -o @.out;./@out |
184259
| cpp | g++ % -o @.out;./@out |
185260
| hs | ghci % |
261+
| java | javac %;java @ |
186262
| js | node % |
187263
| m | matlab |
188264
| ml | ocaml % -o @.out;./@.out |

doc/executioner.txt

Lines changed: 108 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*executioner.txt* For Vim version 8.1 Last change: 2018 December 25
1+
*executioner.txt* For Vim version 8.1 Last change: 2019 January 01
22

33
_____ _ _ ~
44
| ___| | | (_) ~
@@ -7,8 +7,8 @@
77
| |___> < __/ (__| |_| | |_| | (_) | | | | __/ | ~
88
\____/_/\_\___|\___|\__,_|\__|_|\___/|_| |_|\___|_| ~
99

10-
A Vim plugin to easily execute files in the terminal ~
11-
or a separate buffer. ~
10+
A Vim plugin to execute files in a terminal window ~
11+
or a separate buffer. ~
1212

1313

1414
Reference Manual ~
@@ -20,15 +20,16 @@ CONTENTS *executioner-contents*
2020
1. Intro....................................|executioner-intro|
2121
2. Functionality............................|executioner-functionality|
2222
2.1 Commands............................|executioner-commands|
23+
2.2.1 Terminal Window vs. Buffer....|executioner-terminal-vs-buffer|
2324
2.2 Variables...........................|executioner-variables|
2425
3. Mappings.................................|executioner-mappings|
2526

2627
==============================================================================
2728
1. Intro *executioner-intro*
2829

29-
Executioner is a plugin that allows you to easily execute files in the
30-
terminal or a separate buffer straight from Vim. You can find the most updated
31-
version of the plugin from:
30+
Executioner is a plugin that allows you to execute files in a terminal window
31+
or a separate buffer straight from Vim. You can find the most updated version
32+
of the plugin from:
3233

3334
https://github.com/EvanQuan/vim-executioner
3435

@@ -42,33 +43,121 @@ you configure how certain files are to be ran.
4243
------------------------------------------------------------------------------
4344
2.1 Commands *executioner-commands*
4445

46+
This plugin comes with 5 commands:
47+
48+
Each command takes the name of a file as an optional argument, optionally
49+
followed by any command-line arguments. Without any arguments, the current
50+
buffer that is executing the command will be ran with no arguments.
51+
4552
:Executioner [file] [args] *:Executioner*
4653

47-
The file will be executed in in a |shell|, where any output will be printed
48-
there.
54+
The file will be executed in a |shell|, where any output will be printed
55+
there. For example: >
56+
57+
:Executioner
58+
<
59+
will attempt to execute the current buffer with no command-line arguments. >
60+
61+
:Executioner test.py
62+
<
63+
will attempt to execute "test.py" in the current working directory with no
64+
command-line arguments. >
65+
66+
:Executioner test.py foo bar 4
67+
<
68+
will attempt to execute "test.py" in the current working directory, with the
69+
command-line arguments "foo", "bar" and "4".
4970

5071
:ExecutionerHorizontal [file] [args] *:ExecutionerHorizontal*
5172

5273
If Vim has |terminal| window support, then the file will be executed in
53-
a horizontally-split terminal window. Once the program is completed, the
54-
output will be saved in a 'readonly' buffer.
74+
a horizontally-split terminal window. Once the program execution is completed,
75+
the output will be saved in a 'readonly' buffer.
5576

5677
Otherwise, the file will be executed in a shell and its output will be saved
5778
in a horizontally-split 'readonly' buffer. The difference is that without
5879
|terminal| support, no input from the user can be made during the program's
5980
runtime.
6081

82+
:ExecutionerHorizontalBuffer [file] [args] *:ExecutionerHorizontalBuffer*
83+
84+
Same as `:ExecutionerHorizontal` with no |terminal| window support, forcing
85+
a shell to execute the file and save the output in a horizontally-split
86+
'readonly' buffer.
87+
6188
:ExecutionerVertical [file] [args] *:ExecutionerVertical*
6289

6390
If Vim has |terminal| window support, then the file will be executed in
64-
a vertically-split terminal window. Once the program is completed, the
65-
output will be saved in a 'readonly' buffer.
91+
a vertically-split terminal window. Once the program execution is completed,
92+
the output will be saved in a 'readonly' buffer.
6693

6794
Otherwise, the file will be executed in a shell and its output will be saved
6895
in a vertically-split 'readonly' buffer. The difference is that without
6996
|terminal| support, no input from the user can be made during the program's
7097
runtime.
7198

99+
:ExecutionerVerticalBuffer [file] [args] *:ExecutionerVerticalBuffer*
100+
101+
Same as `:ExecutionerVertical` with no |terminal| window support, forcing
102+
a shell to execute the file and save the output in a vertically-split
103+
'readonly' buffer.
104+
105+
------------------------------------------------------------------------------
106+
2.2.1 Terminal Window vs. Buffer *executioner-terminal-vs-buffer*
107+
108+
There are advantages and disadvantages to using either the terminal or buffer
109+
for split window execution. Perhaps some day in the future this distinction
110+
will no longer exist and there will be a unified solution.
111+
112+
Terminal~
113+
Pros
114+
- Accepts standard input from user
115+
- Prints standard output during program execution
116+
Cons
117+
- Cannot execute multiple commands directly
118+
- Does not accept standard input and output redirection
119+
120+
Buffer~
121+
Pros
122+
- Can execute multiple commands
123+
- Accepts standard input and output redirection
124+
Cons
125+
- Does not accept standard input from user
126+
- Prints standard output after program execution is complete
127+
128+
Standard Input and Standard Output~
129+
130+
If you running a version of Vim that has terminal window support, (i.e.
131+
`:echo has("terminal")` returns `1`), then the horizontal and vertical
132+
commands open an interactive terminal window which updates live as the program
133+
is being executed. This allows for user input from standard input, and
134+
displaying of standard output as it is being printed.
135+
136+
Without the terminal feature available, the horizontal and vertical commands
137+
run the program until completion, and store the standard output of the
138+
executed program in a read-only buffer. Due to this reason, it will not work
139+
for programs that require user input and will not update the standard output
140+
over the course of the program execution.
141+
142+
Multiple Commands~
143+
144+
Certain file types that involve multiple commands to be executed, such as
145+
compiling before executing, do not work with terminal windows. This is because
146+
terminal windows treat every space-separated term after the first argument as
147+
command-line arguments, including ones that end with `;`.
148+
149+
Any terminal window command that involves multiple commands will fall back to
150+
the buffer equivalent if multiple commands are found.
151+
152+
Input and Output Redirection~
153+
154+
For the same reason as multiple commands, terminal windows treat every
155+
space-separated term after the first argument as a command-line argument,
156+
including `>`, `<`, and `|` characters.
157+
158+
Any terminal window command that involves input redirection will fall back to
159+
the buffer equivalent if input redirection operators are found.
160+
72161
------------------------------------------------------------------------------
73162
2.2 Variables *executioner-variables*
74163

@@ -128,6 +217,7 @@ Type: |Dictionary|
128217
'c' : 'gcc % -o @.out;./@.out',
129218
'cpp' : 'g++ % -o @.out;./@.out',
130219
'hs' : 'ghci %',
220+
'java' : 'javac %;java @',
131221
'js' : 'node %',
132222
'm' : 'matlab',
133223
'ml' : 'ocaml % -o @.out;./@.out',
@@ -196,6 +286,12 @@ For example, I personally use: >
196286
nnoremap <silent> <leader>hrf :ExecutionerHorizontal<Return>
197287
nnoremap <silent> <leader>vrf :ExecutionerVertical<Return>
198288
289+
" Run current buffer with input redirected from input.txt
290+
"
291+
nnoremap <silent> <leader>ri :ExecutionerBuffer % < input.txt<Return>
292+
nnoremap <silent> <leader>hri :ExecutionerHorizontalBuffer % < input.txt<Return>
293+
nnoremap <silent> <leader>vri :ExecutionerVerticalBuffer % < input.txt<Return>
294+
199295
" run.sh
200296
"
201297
nnoremap <silent> <leader>rr :Executioner run.sh<Return>

0 commit comments

Comments
 (0)