Run any file and show output inside vim.
With config
let g:run_mapping = 'go' " default mapping
let g:run_cmd = {
\'c': 'gcc -Wall -Wextra -std=c99 -pedantic',
\'c_plus': './a.out',
\'java': 'javac -Xdiags:verbose -Xlint:unchecked',
\'java_plus': 'java %:r',
\'python': 'python',
\'javascript': 'node',
\'tsx': 'tsc --outFile %t %',
\'tsx_plus': 'node %t',
\'vim': 'source',
\}
Open a tmp.c
or tmp.py
file and Press go in NORMAL mode. Vim will run the file and split a window to display the output.
How to install
-
Plugin 'leafOfTree/vim-run'
-
cd ~/.vim/bundle && \ git clone https://github.com/leafOfTree/vim-run --depth 1
-
Plug 'leafOfTree/vim-run' :PlugInstall
-
Or manually, clone this plugin to
path/to/this_plugin
, and add it tortp
in vimrcset rtp+=path/to/this_plugin
Please stay up to date. Feel free to open an issue or a pull request.
-
{ key: <filetype>, value: <cmd> }
-
{ key: <filetype>_plus, value: <cmd> }
-
description:
Set
<cmd>
for<filetype>
. The filename is appended to the<cmd>
.-
If there are special chars in
<cmd>
, they will be replaced with a proper value. Meanwhile the filename won't be appended to the<cmd>
.Special chars Value % Filename %:r Filename without extension %t Temp filename given by vim -
Optional: set
<cmd>
for<filetype>_plus
which runs after the previous one. Useful when the previous only compiles the file.
-
-
type:
Dictionary
-
default:
Undefined
-
example:
let markdown_to_html = 'pandoc \ --metadata title="%" \ -c http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css \ -s % -o %:r.html' let g:run_cmd = { \'c': 'gcc -Wall -Wextra -std=c99 -pedantic', \'c_plus': './a.out', \'cpp': 'g++ -Wall -Wextra -pedantic', \'javascript': 'node', \'python': 'python', \'markdown': markdown_to_html, \'markdown_plus': 'open %:r.html', \'vim': 'source', \}
Note: you need to use 'source'
for vim
files.
-
description: key mapping to run the current file in Normal mode.
-
default:
'go'
-
example:
let g:run_mapping = '<F5>'
Or you can map key as usual
nnoremap <c-cr> <Cmd>call run#Run()<cr>
inoremap <c-cr> <Cmd>call run#Run()<cr>
Focus the output window. Default: 0
. (0
or 1
).
Let the output window scroll to bottom. Default: 0
. (0
or 1
).
Split output window vertically. Default: 0
. (0
or 1
).
Show debug messages. Default: 0
. (0
or 1
).
You can add syntax/run-<filetype>.vim
to custom <filetype>
output's syntax highlighting. Examples are syntax/run-go.vim
, syntax/run-c.vim
, ...