Ⅰ. 插件描述
dotenv.vim: Basic support for .env and ProcfileⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tpope/dotenv-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tpope/dotenv-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tpope/dotenv-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tpope/vim-dotenv
Ⅳ. 文档说明
# dotenv.vim
This plugin provides basic support for .env and Procfile.
Interactive Usage
Use :Dotenv {file} or :Dotenv {dir} to load a .env file and set the
corresponding environment variables in Vim. Use :verbose Dotenv to see what
variables are actually being set.
Projections
With [projectionist.vim][] and [dispatch.vim][] installed, you'll get a
default :Start of foreman start for projects with a Procfile, and a
default :Dispatch of foreman check for the Procfile itself.
Dispatch
If you call :Dispatch foreman run whatever or :Dispatch dotenv whatever,
the compiler will be correctly selected for the whatever command.
API
While the above are all marginally helpful, this is the use case that inspired
the plugin. Other plugins can call DotenvGet('VAR') to get the value of$VAR globally or from the current buffer's .env. Here's a wrapper to
optionally use DotenvGet() if it's available.
function! s:env(var) abort
return exists('*DotenvGet') ? DotenvGet(a:var) : eval('$'.a:var)
endfunction
let db_url = s:env('DATABASE_URL')
There's also DotenvExpand(), a drop-in replacement for expand().
function! s:expand(expr) abort
return exists('*DotenvExpand') ? DotenvExpand(a:expr) : expand(a:expr)
endfunction
License
Copyright © Tim Pope. Distributed under the same terms as Vim itself.
See :help license.