Ⅰ. 插件描述
Execute current file open in vimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'samtebbs33/vim-exec'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'samtebbs33/vim-exec'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'samtebbs33/vim-exec'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/samtebbs33/vim-exec
Ⅳ. 文档说明
# vim-exec
A vim plugin that executes the current file.

Contents
Installation
Install pathogen, and then clone this repo into your .vim/bundle directory.
cd ~/.vim/bundle && git clone https://github.com/SamTebbs33/vim-execUsage
Key mapping
The default key mapping is to F12, which can be changed by reassigning g:vim_exec_key in your .vimrc and then calling VimExecMap().
" Map to <leader>e
let g:vim_exec_key = "<leader>e"
call VimExecMap()Adding commands
Some common commands are provided by default (run :call VimExecCmds() to see a list of those), but more can be added easily.
The variable that stores the commands is called g:vim_exec_cmds and is a dictionary, where the key is the filetype and the value is the command to execute.
To create a new command or override an existing one:
let g:vim_exec_cmds["filetype"] = "cmd"Where "filetype" is the filetype you want the command to apply to and "cmd" is the command itself. Use % to represent the path to the current file. Note that : is added to the beginning and <CR> is not needed at the end. Open a file of the filetype and press the key that is bound to VimExec to test the new command.
If you'd like to add a command that will be supplied by default, fork the repo, edit the plugin/vim-exec.vim file and add the filetype and command to the end of the g:vim_exec_cmds dictionary.
let g:vim_exec_cmds = {..., "new-filetype" : "new-comand"}Then open a pull request. I will merge the pull request if the change is relevant and doesn't do anything malicious to the user's system (i.e, no rm -rf /*)
Clearing the terminal
By default, VimExec will not clear the terminal screen (not the vim buffer window) before executing a command. To enable this:
let g:vim_exec_clear = 1To change the command used to clear the screen (It is clear by default):
let g:vim_exec_clearcmd = "cls"Vimux/tmux support
vim-exec can output to a tmux pane rather than the default terminal if vimux is installed. To enable this:
let g:vim_exec_vimux = 1You must be runnign an instance of tmux in order for this to work.
Default filetypes
Below is a list of the filetypes that are supported by default and their requirements (if there are any).
- Python
- OCaml
- VimScript
- JavaScript: Node.js
- HTML
- Bash script
- Haskell: Ghci
See the "Adding execution commands" section for info on adding more filetypes. More will be added to the default set when they are thought of.