{"id":16406489,"url":"https://github.com/wincent/replay","last_synced_at":"2025-02-23T21:22:52.900Z","repository":{"id":66829532,"uuid":"73673914","full_name":"wincent/replay","owner":"wincent","description":"🔁 Convenient re-run of last recorded Vim macro","archived":false,"fork":false,"pushed_at":"2023-10-24T22:25:08.000Z","size":20,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T15:43:35.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wincent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-14T06:30:49.000Z","updated_at":"2023-10-08T14:44:14.000Z","dependencies_parsed_at":"2023-05-10T17:00:46.581Z","dependency_job_id":"3fb2f759-d829-4705-84ab-c9569bcbdba6","html_url":"https://github.com/wincent/replay","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Freplay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Freplay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Freplay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Freplay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wincent","download_url":"https://codeload.github.com/wincent/replay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240380380,"owners_count":19792287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T06:09:55.493Z","updated_at":"2025-02-23T21:22:52.851Z","avatar_url":"https://github.com/wincent.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# replay\u003ca name=\"replay-replay\" href=\"#user-content-replay-replay\"\u003e\u003c/a\u003e\n\n\n## Intro\u003ca name=\"replay-intro\" href=\"#user-content-replay-intro\"\u003e\u003c/a\u003e\n\nReplay sets up a mapping (\u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e by default) to execute the last recorded macro.\n\nWithout Replay, you can execute a macro in register \u0026quot;q\u0026quot; by hitting \u003cstrong\u003e`@`\u003c/strong\u003e followed by \u0026quot;q\u0026quot;, but that is relatively uncomfortable to type. Once you've played the macro back once, you can play it again with \u003cstrong\u003e`@@`\u003c/strong\u003e, which is easier but still not as comfortable as just hitting \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e.\n\n\u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e is chosen because its standard behavior is not super useful (moves down a line, placing the cursor on the first non-blank character). You can still use \u003cstrong\u003e`+`\u003c/strong\u003e to the same effect, or an alternative like \u003cstrong\u003e`j`\u003c/strong\u003e which is similar but does not move to the first non-blank character.\n\nReplay won't do anything in \u0026quot;special\u0026quot; buffers such as \u003cstrong\u003e`quickfix`\u003c/strong\u003e listings or [NERDTree](https://github.com/scrooloose/nerdtree) explorers, because in those the \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e actually does have useful navigation behavior.\n\n\n## Implementation\u003ca name=\"replay-implementation\" href=\"#user-content-replay-implementation\"\u003e\u003c/a\u003e\n\nI originally had this idea implemented as a simple mapping of \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e to \u003cstrong\u003e`@@`\u003c/strong\u003e, but that was problematic for a couple of reasons: \u003cstrong\u003e`@@`\u003c/strong\u003e would only replay the last executed macro, which meant that on the first run it would complain with error \u003cstrong\u003e`E748`\u003c/strong\u003e that there was \u0026quot;No previously used register\u0026quot;; this behavior was confusing because it would still work, sometimes, based on information recovered from the \u003cstrong\u003e`viminfo`\u003c/strong\u003e file. If you're one of those who mostly records into the \u0026quot;q\u0026quot; register, this meant that the mapping usually worked, but not always, which is a pretty annoying state of affairs.\n\nAs such, Replay tries to provide \u0026quot;last recorded\u0026quot; rather than \u0026quot;last executed\u0026quot; semantics. It does this by overriding the \u003cstrong\u003e`q`\u003c/strong\u003e mapping to take a snapshot of the current register state when recording a macro. When you hit \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e, it figures out which register was updated and executes that one.\n\nNote that this is an imprecise art because Vim doesn't provide any hooks that would allow you to know for sure which is the last-modified register (for example if you recorded to multiple registers); Replay will detect the first one with updated contents.\n\nOnce you've replayed a macro once with \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e, you can mash it repeatedly at will. You can also make use of recursion (ie. hitting \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e during a macro recording) like you would recording any other Vim macro (although note that \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e won't do anything during recording, only during playback).\n\nIf you then execute a macro from a different register (say, \u0026quot;w\u0026quot;), then hitting \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e will repeat that macro instead of the last recorded one. This behavior is based on the notion that you usually want to repeat the last thing you did, whether that be the last thing you recorded or the last thing you executed, whichever happened later.\n\nNote that the heuristic here will do what you want most of the time, but it is not infallible. For example, you could record into register \u0026quot;q\u0026quot;, then play back register \u0026quot;w\u0026quot;, and when you hit \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e Replay will execute register \u0026quot;q\u0026quot; rather than \u0026quot;w\u0026quot;. This is due to the lack of hooks already mentioned above.\n\nAs a last resort fallback, if neither a last-recorded nor last-played macro is detected, Replay will attempt to execute the macro in the \u0026quot;q\u0026quot; register, as that is a popular default register choice.\n\n\n## Installation\u003ca name=\"replay-installation\" href=\"#user-content-replay-installation\"\u003e\u003c/a\u003e\n\nTo install Replay, use your plug-in management system of choice.\n\nIf you don't have a \u0026quot;plug-in management system of choice\u0026quot; and your version of Vim has `packages` support (ie. `+packages` appears in the output of `:version`) then you can simply place the plugin at a location under your `'packpath'` (eg. `~/.vim/pack/bundle/start/replay` or similar).\n\nFor older versions of Vim, I recommend [Pathogen](https://github.com/tpope/vim-pathogen) due to its simplicity and robustness. Assuming that you have Pathogen installed and configured, and that you want to install Replay into `~/.vim/bundle`, you can do so with:\n\n```\ngit clone https://github.com/wincent/replay.git ~/.vim/bundle/replay\n```\n\nAlternatively, if you use a Git submodule for each Vim plug-in, you could do the following after `cd`-ing into the top-level of your Git superproject:\n\n```\ngit submodule add https://github.com/wincent/replay.git ~/vim/bundle/replay\ngit submodule init\n```\n\nTo generate help tags under Pathogen, you can do so from inside Vim with:\n\n```\n:call pathogen#helptags()\n```\n\n\n## Mappings\u003ca name=\"replay-mappings\" href=\"#user-content-replay-mappings\"\u003e\u003c/a\u003e\n\n\n### `\u003cPlug\u003e(Replay)`\u003ca name=\"replay-plugreplay\" href=\"#user-content-replay-plugreplay\"\u003e\u003c/a\u003e\n\nReplay maps \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e to \u003cstrong\u003e[`\u003cPlug\u003e(Replay)`](#user-content-plugreplay)\u003c/strong\u003e, which executes the last-recorded macro, or the last-executed macro, as described in \u003cstrong\u003e[`replay-implementation`](#user-content-replay-implementation)\u003c/strong\u003e.\n\nTo ues an alternative mapping instead, create a different one in your \u003cstrong\u003e`.vimrc`\u003c/strong\u003e using \u003cstrong\u003e`:nmap`\u003c/strong\u003e:\n\n```\n\" Instead of \u003cCR\u003e, use \u003cLeader\u003em\nnmap \u003cunique\u003e \u003cLeader\u003em \u003cPlug\u003e(Replay)\n```\n\n\n## Options\u003ca name=\"replay-options\" href=\"#user-content-replay-options\"\u003e\u003c/a\u003e\n\n\u003cp align=\"right\"\u003e\u003ca name=\"greplayloaded\" href=\"#user-content-greplayloaded\"\u003e\u003ccode\u003eg:ReplayLoaded\u003c/code\u003e\u003c/a\u003e\u003c/p\u003e\n\n### `g:ReplayLoaded` (any, default: none)\u003ca name=\"replay-greplayloaded-any-default-none\" href=\"#user-content-replay-greplayloaded-any-default-none\"\u003e\u003c/a\u003e\n\nTo prevent Replay from being loaded, set \u003cstrong\u003e[`g:ReplayLoaded`](#user-content-greplayloaded)\u003c/strong\u003e to any value in your \u003cstrong\u003e`.vimrc`\u003c/strong\u003e. For example:\n\n```\nlet g:ReplayLoaded=1\n```\n\n\n## Website\u003ca name=\"replay-website\" href=\"#user-content-replay-website\"\u003e\u003c/a\u003e\n\nSource code:\n\n- https://github.com/wincent/replay\n- https://gitlab.com/wincent/replay\n- https://bitbucket.org/ghurrell/replay\n\nOfficial releases are listed at:\n\nhttp://www.vim.org/scripts/script.php?script_id=5483\n\n\n## License\u003ca name=\"replay-license\" href=\"#user-content-replay-license\"\u003e\u003c/a\u003e\n\nCopyright (c) 2016-present Greg Hurrell\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u0026quot;Software\u0026quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \u0026quot;AS IS\u0026quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n## Development\u003ca name=\"replay-development\" href=\"#user-content-replay-development\"\u003e\u003c/a\u003e\n\n\n### Contributing patches\u003ca name=\"replay-contributing-patches\" href=\"#user-content-replay-contributing-patches\"\u003e\u003c/a\u003e\n\nPatches can be sent via mail to greg@hurrell.net, or as GitHub pull requests at: https://github.com/wincent/replay/pulls\n\n\n### Cutting a new release\u003ca name=\"replay-cutting-a-new-release\" href=\"#user-content-replay-cutting-a-new-release\"\u003e\u003c/a\u003e\n\nAt the moment the release process is manual:\n\n- Perform final sanity checks and manual testing.\n- Update the [replay-history](#user-content-replay-history) section of the documentation.\n- Regenerate the documentation:\n\n```\ndocvim README.md doc/replay.txt\n```\n\n- Verify clean work tree:\n\n```\ngit status\n```\n\n- Tag the release:\n\n```\ngit tag -s -m \"$VERSION release\" $VERSION\n```\n\n- Publish the code:\n\n```\ngit push origin main --follow-tags\ngit push github main --follow-tags\n```\n\n- Produce the release archive:\n\n```\ngit archive -o replay-$VERSION.zip HEAD -- .\n```\n\n- Upload to http://www.vim.org/scripts/script.php?script_id=5483\n\n\n## Authors\u003ca name=\"replay-authors\" href=\"#user-content-replay-authors\"\u003e\u003c/a\u003e\n\nReplay is written and maintained by Greg Hurrell \u0026lt;greg@hurrell.net\u0026gt;.\n\nOther contributors that have submitted patches include (in alphabetical order):\n\n- Paweł Tomak\n\n\n## History\u003ca name=\"replay-history\" href=\"#user-content-replay-history\"\u003e\u003c/a\u003e\n\n\n### 1.0 (6 March 2019)\u003ca name=\"replay-10-6-march-2019\" href=\"#user-content-replay-10-6-march-2019\"\u003e\u003c/a\u003e\n\n- Guard against user remapping of \u003cstrong\u003e`@`\u003c/strong\u003e (https://github.com/wincent/replay/issues/4).\n\n\n### 0.3 (15 November 2016)\u003ca name=\"replay-03-15-november-2016\" href=\"#user-content-replay-03-15-november-2016\"\u003e\u003c/a\u003e\n\n- Don't move down a line when hitting \u003cstrong\u003e`\u003cCR\u003e`\u003c/strong\u003e during macro recording.\n\n\n### 0.2 (14 November 2016)\u003ca name=\"replay-02-14-november-2016\" href=\"#user-content-replay-02-14-november-2016\"\u003e\u003c/a\u003e\n\n- Make mapping customizable via \u003cstrong\u003e[`\u003cPlug\u003e(Replay)`](#user-content-plugreplay)\u003c/strong\u003e.\n- Avoid ugly stack traces for recursive macros that exceed \u003cstrong\u003e`'maxfuncdepth'`\u003c/strong\u003e.\n\n\n### 0.1 (14 November 2016)\u003ca name=\"replay-01-14-november-2016\" href=\"#user-content-replay-01-14-november-2016\"\u003e\u003c/a\u003e\n\n- Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwincent%2Freplay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwincent%2Freplay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwincent%2Freplay/lists"}