Code Monkey home page Code Monkey logo

dmacro.vim's Introduction

dmacro.nvim / dmacro.vim

Caution

  • You need to use neovim 0.10.0 or later.
  • You need to use vim with patch 9.1.0597.

Text editors have evolved to support input in different ways.

  • Word completion based on dictionary data (e.g. CTRL-X completion in Vim)
  • Code fragment completion based on dictionary data (e.g. Snippet Completion)
  • Contextual, rule-based word completion (e.g. Language Server Protocol)
  • Completion of larger code fragments using generative AI (GitHub Copilot)

All of these were hailed as revolutionary when they first appeared. What's the next big assistive feature? I say operation completion. Currently, completion is for new code. But most coding isn't new creation. It's overwriting, like editing or updating. Shouldn't this be supported?

Related works

Example

dmacro.webm

This plugin dynamically defines a macro. You do not need to make any markers for the macro. To define a macro, this plugin detects the reputation as follows:

  • If you enter the same key sequence twice (e.g. abcabc), this plugin will define a macro with the key sequence (e.g. abc).

    graph LR
      start(( )) --> a1((a))
      subgraph 1st
      a1 --> b1((b))
      b1 --> c1((c))
      end
      subgraph 2nd
      c1 --> a2((a))
      a2 --> b2((b))
      b2 --> c2((c))
      end
      subgraph 3rd
      c2 --> dmacro(dmacro)
      dmacro -.- a3((a))
      subgraph MacroExecution
      a3 -.- b3((b))
      b3 -.- c3((c))
      end
      end
      c3 --> quit(( ))
    
    Loading
  • If you type the subsequence (e.g. a) of the previous key sequence (e.g. abc), this plugin will define a macro with the rest of the previous sequence (e.g. bc). After expanding the macro, the whole sequence (e.g. abc) will be the macro.

    graph LR
      start(( )) --> a1((a))
      subgraph 1st
      a1 --> b1((b))
      b1 --> c1((c))
      end
      subgraph 2nd
      c1 --> a2((a))
      a2 --> dmacro1(dmacro)
      dmacro1 -.- b2((b))
      subgraph MacroExecution_1
      b2 -.- c2((c))
      end
      end
      subgraph 3rd
      c2 --> dmacro2(dmacro)
      dmacro2 -.- a3((a))
      subgraph MacroExecution_2
      a3 -.- b3((b))
      b3 -.- c3((c))
      end
      end
      c3 --> quit(( ))
    
    Loading

Usage

You need to bind the <Plug>(dmacro-play-macro) to a key sequence.

vim.keymap.set({ "i", "n" }, '<C-y>', '<Plug>(dmacro-play-macro)')
inoremap <C-y> <Plug>(dmacro-play-macro)
nnoremap <C-y> <Plug>(dmacro-play-macro)

Licence

This software is released under the MIT licence.

dmacro.vim's People

Contributors

tani avatar futsuuu avatar mityu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.