Coder Social home page Coder Social logo

medit's Introduction

NOTE

Note You don't need this plugin! Instead, there's a very easy keymap that you can use that will do basically the exact same thing!

Neovim Lua:

vim.keymap.set("n", "<Leader>eq", function()
  -- ask user for which register they'd like to edit
	local reg = vim.fn.getchar("Macro Register: ")

	-- Obtain the content of the register
	local reg_content = vim.fn.getreg("q")

	-- Present the register content to the user to edit
	local replaced_reg_content = vim.fn.input("> ", reg_content)

	-- Take the user input and put it back into the register
	vim.fn.setreg(reg, replaced_reg_content)
end, { silent = true, desc = "Edit a macro" })

The vimscript version is almost identical because vim.fn.xxxx is simply a wrapper around the vimscript functions.

Medit (Macro Edit)

Ever work on a long macro and need to change something about it half way through? sure ya have. This'll let you open up a nice window (either floating or split) where you can edit your macro. Neat huh?

Demo

asciicast

Default Usage

open up the window with

  <Leader>q{macro register you care about}

Then when you're done editing, just hit q and it'll save the macro to the register you wanted, or hit <esc> to abort! Cool!

Setup

MEdit should have default mappings out of the box, but you can set your own mappings if you want using let g:medit_no_mappings = 1 and then nmap {whatever you want} <Plug>MEdit

Coming Soon

  • Preview for changes to lines in the buffer you called things from
  • Preserving your clipboard

medit's People

Contributors

zdcthomas avatar

Stargazers

Andy Shevchenko avatar ryoppippi avatar  avatar Alexey Nekrasov avatar Qyriad avatar Cyril Labitte avatar Andrey Bolduzev avatar Tsuyoshi CHO avatar Adelar da Silva Queiróz avatar Yuta Katayama avatar aiya000 avatar Hirokazu Hata avatar Martin Kinoo avatar Jim Denton avatar

Watchers

James Cloos avatar  avatar

medit's Issues

Bug in simple script?

I tried the simple script in your readme, and had to change it to the following to fix some issues:

vim.keymap.set("n", "<Leader>eq", function()
  -- ask user for which register they'd like to edit
  print("Macro register: ")
  local reg = vim.fn.getcharstr()

  -- obtain the content of the register
  local reg_content = vim.fn.getreg(reg)

  -- present the register content to the user to edit
  local replaced_reg_content = vim.fn.input("> ", reg_content)

  -- take the user input and put it back into the register
  vim.fn.setreg(reg, replaced_reg_content)
end, { silent = true, desc = "Edit a macro" })

With these fixes in place, I was able to edit the register. However, any special characters, such as backspace, are lost. Do you have any idea on how we can preserve them?

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.