Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.36 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.36 KB

Instant-substituter.nvim

Substitute string with one shortcut.

In my daily coding, I repeatedly replace ' with ". For that, I used :s/'/"/g or r". However, that's annoying to type them again and again.

So, I made this plugin. This makes it possible to configure substitute shortcuts easily. For example, focusing on the line you want to execute substitution then pressing gz replaces ' with " whole of the focused line.

Advantages

  • Dot-repeat is supported
  • Replace multiple lines simultaneously in VISUAL mode
  • Easy configuration
  • Not only replacing but also swapping two strings

Demo

demo.mov

Installation

Using Lazy.nvim

{ "kjuq/instant-substituter.nvim" }

Configuration

Example

{
  "kjuq/instant-substituter.nvim",
  opts = {
    keys = {
      ["gz"] = { "'", '"', { swap = true } }, -- swap ' for "
      ["<C-l>"] = { "-", "+" }, -- just replace - with +
      ["<leader>o"] = { "var", "let" }, -- not only symbols, words are also supported
    },
  },
}
["<A>"] = { "<B>", "<C>" }

Put the key to activate a substitution in <A>. It replaces a string <B> with <C>.

Usage

Focus the line and hit the key, then replace ALL of the texts you specified in the configuration.