All Projects → da-x → name-assign.vim

da-x / name-assign.vim

Licence: Unlicense license
Vim plugin to automate replacing expressions with assigned variables in any programming language

Programming Languages

Vim Script
2826 projects

Projects that are alternatives of or similar to name-assign.vim

Vim Anyfold
Language agnostic vim plugin for folding and motion based on indentation.
Stars: ✭ 208 (+362.22%)
Mutual labels:  vim-plugins
lh-tags
ctags base updating, and browsing from vim
Stars: ✭ 25 (-44.44%)
Mutual labels:  vim-plugins
writable search.vim
Grep for something, then write the original files directly through the search results.
Stars: ✭ 47 (+4.44%)
Mutual labels:  vim-plugins
Is.vim
incremental search improved - successor of incsearch.vim
Stars: ✭ 209 (+364.44%)
Mutual labels:  vim-plugins
vim-stylus
A better vim plugin for stylus, including proper and up-to-date syntax highligting, indentation and autocomplete
Stars: ✭ 49 (+8.89%)
Mutual labels:  vim-plugins
vim-sass-colors
sass/scss/less/css color literal and color variable highlighting (works with imports)
Stars: ✭ 24 (-46.67%)
Mutual labels:  vim-plugins
Vim Go
Go development plugin for Vim
Stars: ✭ 14,085 (+31200%)
Mutual labels:  vim-plugins
vimapt
A package manager for vim (VimApt => Vim's Advanced Package Tools)
Stars: ✭ 16 (-64.44%)
Mutual labels:  vim-plugins
vim-modusline
🌈 Mode-specific statusline colors
Stars: ✭ 39 (-13.33%)
Mutual labels:  vim-plugins
vim-drawer
VimDrawer is a Vim plugin to group related buffers in tabs automatically by the file name.
Stars: ✭ 26 (-42.22%)
Mutual labels:  vim-plugins
Vim Arpeggio
Vim plugin: Mappings for simultaneously pressed keys
Stars: ✭ 216 (+380%)
Mutual labels:  vim-plugins
vim-searchant
searchant.vim is obsoleted by vim-searchhi
Stars: ✭ 55 (+22.22%)
Mutual labels:  vim-plugins
ipynb notedown.vim
vim plugin for editing jupyter notebook (ipynb) files through notedown
Stars: ✭ 27 (-40%)
Mutual labels:  vim-plugins
Vim Racket
vim bundle for Racket
Stars: ✭ 207 (+360%)
Mutual labels:  vim-plugins
dotfiles
My hand crafted .dotfiles 🤚🛠❤️
Stars: ✭ 49 (+8.89%)
Mutual labels:  vim-plugins
Vim Vspec
Vim plugin: Testing framework for Vim script
Stars: ✭ 207 (+360%)
Mutual labels:  vim-plugins
tmux-zsh-vim-titles
Unified terminal titles in tmux, zsh, and vim/nvim
Stars: ✭ 28 (-37.78%)
Mutual labels:  vim-plugins
vim-debugstring
Debug printf()-style at the speed of light
Stars: ✭ 30 (-33.33%)
Mutual labels:  vim-plugins
vim-phpstan
A Vim plugin for PHPStan - https://github.com/phpstan/phpstan. It calls `phpstan` to do static analysis of your PHP code and displays the errors in Vim's quickfix list.
Stars: ✭ 26 (-42.22%)
Mutual labels:  vim-plugins
tabulous
Vim plugin for setting the tabline including the tab page labels. It is lightweight and written in pure Vim script.
Stars: ✭ 21 (-53.33%)
Mutual labels:  vim-plugins

name-assign.vim

Short introduction

This repository provides a Vim plugin to automate replacing expressions with assigned variables in multiple programming language.

An animated Gif is worth a 1,000 words:

Description

In many programming languages, a common editing operation is to move subexpressions out of a nested expression into their own assigned names.

To illustrate, suppose we want to transform the following:

call_func(some_code, some_complex_and_long_expression);

Into the following:

let var = some_complex_and_long_expression;
...
call_func(some_code, var);

There can be any amount of lines between the top expression and the variable assignment.

The plugin supports the following languages: Rust, C, C++, Go, VimScript, JavaScript, TypeScript, Python, LISP, Scheme, Racket, Clojure, Erlang, Elixir, Haskell and PureScript.

Usage instructions

First, note that the default kbd combination is Alt - =, and it is bound in visual mode.

Each usage has four steps:

  • Mark the expression to replace with a visual selection.
  • Hit the key combination, pick the name of the expression.
  • Now in 'placement mode', move the assignment expression with Up or Down, or using k or j.
  • End placing the assignment with Esc or Return.

Overriding mappings

The trigger to activate can be set to a different key:

vmap <leader>b <Plug>NameAssign

It is also possible to override mappings done for the placement mode to different keys, for example:

let g:name_assign_mode_maps = { "up" : ["n"],  "down" : ["N"] }

These mappings are temporary and buffer local, so they will not affect any global mappings for the specified keys.

Here's the full list of actions:

  • up : For moving the placement up
  • down : For moving the placement down
  • settle : For ending placement

To Do

  • Extend support to more languages.
  • Allow to customize the content of the @ register after the operation. Currently it will contain the entered name.
  • Don't liter the undo history too much with the movement, or try to rely on vim-schlepp that probably does it better.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].