vim-runfile


Ⅰ. 插件描述

Uniform run command for interpreted files

Ⅱ. 基本信息

创建日期:  2012-05-14
使用用户:  2
Github星:  3
插件作者:  patrick brisbin

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'pbrisbin/vim-runfile'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'pbrisbin/vim-runfile'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'pbrisbin/vim-runfile'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/pbrisbin/vim-runfile

Ⅳ. 文档说明

# runfile

I was sick of adding a bunch of <Leader>r mappings to "run" the
various executable or interpretable file types I work in. Why not a
single function that auto-magically runs the correct command using some
simple rules based on the file name and type?

It should do the Right Thing most of the time and I should be able to
easily customize and override in .vimrc.

Installation

Use [pathogen][].

$ cd .vim/bundle
$ git clone https://github.com/pbrisbin/vim-runfile

Usage

:Run

Default Rules

If file is executable...    Then :Run means...
                            !%

If the filetype matches...  Then :Run means...
cram                        !cram %
cucumber                    !cucumber %
go                          !go run %
haskell                     !runhaskell %
html                        !$BROWSER %
python                      !python %
ruby                        !ruby -Ilib %
sh                          !/bin/sh %
vim                         source %

Extending

If the maps g:runfile_by_name or g:runfile_by_type exist, they are
merged into the default rules when the plugin first loads.

Example

let g:runfile_by_name = {
    \ 'config.ru': '!rackup %',
    \ }

let g:runfile_by_type = {
    \ 'markdown': '!markdown2pdf %',
    \ 'html'    : '%!tidy',
    \ }

Notes

  1. Right now, the pattern in _by_name is matched against the filename,
    not the full path. I might change that if it seems limiting.
  2. The filename pattern is regex, not glob.
  3. The command part of the mapping can be any vim command, it need not
    execute anything.
  4. The rules are tried in key-alphabetical order, not definition order as you
    might expect or want. This is because of vim, not by design.

添加新评论