https://github.com/fvictorio/vim-extract-variable
Vim plugin to extract an expression to a variable
https://github.com/fvictorio/vim-extract-variable
Last synced: 4 months ago
JSON representation
Vim plugin to extract an expression to a variable
- Host: GitHub
- URL: https://github.com/fvictorio/vim-extract-variable
- Owner: fvictorio
- License: mit
- Created: 2017-11-10T20:05:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T16:27:11.000Z (almost 3 years ago)
- Last Synced: 2025-08-23T01:57:40.371Z (5 months ago)
- Language: Vim Script
- Size: 21.5 KB
- Stars: 26
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/junegunn/vim-plug):
```
Plug 'fvictorio/vim-extract-variable'
```
## Usage
A normal and visual mapping is set: `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` |
| R | `foo <- 42` |
| Ruby | `foo = 42` |
| TypeScript | `const foo = 42` |
| Python | `foo = 42` |
| C# | `var foo = 42;` |
| C++ | `auto foo = 42;` |