lverweijen / vim-irreplaceable

Quickly rename variables the vim way

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Irreplaceable

Let's say you want to replace a variable name. You can use the built-in :substitute command, but this vim plug-in achieves this task faster and more intuitively. If you use the :substitute command often or if you wish vim had support for multiple selections, this plug-in is for you.

I got the idea for this plug-in after reading this blog post by Christoph Hermank.

Example usage

Let's say you want to replace "value" by "saldo" in the snippet below:

if value:
    print("value = {}".format(value))
else:
    print("value is zero")
  • Put the cursor on "value"
  • Press c.iw to change it
  • Type "saldo" in its place

Now you can do the following:

  • Press n to go to next occurrence "value"
  • Press N to go to previous "value"
  • Press . to replace the next occurrence of "value" by "saldo"
  • Press . repeatedly to replace every occurrence of "value" by "saldo"

The end result should look like this:

if saldo:
    print("saldo = {}".format(saldo))
else:
    print("saldo is zero")

Installation

Use some plugin manager, e.g.

Plug 'https://github.com/lverweijen/vim-irrepleaceable.git'

Configuration

Rebind the following to whatever you wish:

  • <Plug>(easy-refactor-y)
  • <Plug>(easy-refactor-d)
  • <Plug>(easy-refactor-c)

By default these are bound to y., d. and c. in normal mode. In visual mode, the default bindings are .y, .d, .c.

About

Quickly rename variables the vim way

License:GNU General Public License v3.0


Languages

Language:Vim Script 100.0%