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

Installation
Use one of the hundred of methods that exist to install a vim plugin. I recommend vim-plug:
Plug 'fvictorio/vim-extract-variable'Usage
A normal and visual mapping is set: <leader>ev. If you use it in visual mode, it extracts the selected text to a variable. The name of the variable will be prompted to you. If you use it in normal mode, the text between parentheses is used.
The declaration is created in the previous line, using O, so it should preserve the indentation if you have autoindent on.
Supported languages
The following languages are supported:
| Language | Result |
|---|---|
| Elixir | foo = 42 |
| Go | foo := 42 |
| JavaScript | const foo = 42 |
| TypeScript | const foo = 42 |
| Python | foo = 42 |
| Ruby | foo = 42 |