{"id":21291682,"url":"https://github.com/jdtsmith/speedrect","last_synced_at":"2025-03-15T16:34:23.275Z","repository":{"id":212387648,"uuid":"610848549","full_name":"jdtsmith/speedrect","owner":"jdtsmith","description":"Quick key bindings and other tools for rectangle-mark-mode","archived":false,"fork":false,"pushed_at":"2024-12-20T18:31:55.000Z","size":146,"stargazers_count":35,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-22T06:24:09.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdtsmith.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.org","contributing":null,"funding":null,"license":"LICENSE","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":"2023-03-07T15:51:14.000Z","updated_at":"2025-01-12T13:33:27.000Z","dependencies_parsed_at":"2023-12-24T19:35:25.907Z","dependency_job_id":"3b472d86-9c1a-4102-aa95-d1f6b093b91a","html_url":"https://github.com/jdtsmith/speedrect","commit_stats":null,"previous_names":["jdtsmith/speedrect"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdtsmith%2Fspeedrect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdtsmith%2Fspeedrect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdtsmith%2Fspeedrect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdtsmith%2Fspeedrect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdtsmith","download_url":"https://codeload.github.com/jdtsmith/speedrect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243760548,"owners_count":20343649,"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-11-21T13:39:10.769Z","updated_at":"2025-03-15T16:34:23.246Z","avatar_url":"https://github.com/jdtsmith.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpeedRect – fast powerful rectangles in Emacs\n\u003ca href=\"https://elpa.gnu.org/packages/speedrect.html\"\u003e\u003cimg alt=\"GNU ELPA\" src=\"https://elpa.gnu.org/packages/speedrect.svg\"/\u003e\u003c/a\u003e \n\n**Quick key bindings and other powerful rectangle tools for Emacs' `rectangle-mark-mode`.**\n\n`SpeedRect` is a small Emacs package that automatically provides convenient \"modal\" single-key bindings and other tools while in `rectangle-mark-mode` (`C-x SPC`, or `C-M-mouse1` drag, by default).\n\n## Features\n\u003cimg width=\"500\" alt=\"image\" align=\"right\" src=\"https://github.com/user-attachments/assets/adcea492-cd51-4123-b5aa-7f0f31eb1029\" /\u003e \n\n- Single-key [bindings](#commands) for all the basic rectangle functions: open, insert string, kill, delete, clear, copy, yank.\n- The rectangle remains selected after most commands, so you can easily _chain_ actions together (kill this column, yank it over there, send to calc, do some math, yank the results back, ...).\n- Easily restore in a future session the last marked rectangle's position, which gets auto-saved.\n- Many additional and powerful rectangle [commands](#commands) beyond those found on `C-x r *`.\n- Change your mind and start a new rectangle from point without leaving `rectangle-mark-mode`.\n- Column shift: slide the marked rectangle position left or right, 1 (hold shift) or 5 (meta-shift) columns at a time (or any number of columns, with a numerical prefix).\n- Delete whitespace from the rectangle boundaries to left or right-align columns.\n- Quickly enter numeric columns with custom formatting and starting value.\n- Increment/decrement selected columns of numbers by any amount.\n- Two-way interaction with `calc` (which can do _anything_):\n   - send row/column sums or tables of data into `calc`\n   - yank processed matrix data atop the current rectangle from `calc`'s stack.\n- Quickly add [multiple cursors](https://github.com/magnars/multiple-cursors.el) on each line of the current rectangle, and return to your marked rectangle when it finishes.\n- Flexibly wrap text within rectangles.\n- A useful help page (`?`). \n\n## Demo\n\u003cdetails\u003e\n\u003csummary\u003eDemo of speedrect's key features\u003c/summary\u003e\n\u003cvideo src='https://github.com/user-attachments/assets/4cc4a1ed-1d29-48b2-a365-2d39ef531d80'/\u003e\u003c/video\u003e\n\u003c/details\u003e\n\n## What's New\n\nSee the release [NEWS](NEWS.org).\n\n## Installation\n\nInstall from ELPA, and arrange to `(require 'speedrect)`.  \n\nFor users of `use-package`:\n\n```elisp\n(use-package speedrect\n  :demand t ; if you use use-package-always-defer=t\n  :config (speedrect-mode))\n```\n\nOr, with `use-package` and `straight`:\n\n```elisp\n(use-package speedrect\n  :straight (speedrect :type git :host github :repo \"jdtsmith/speedrect\")\n  :config (speedrect-mode))\n```\n## Usage\n\nStart `rectangle-mark-mode` as usual (`C-x SPC`, by default).  Hit `?` to summon a help buffer of available key bindings.  By default most commands restart `rectangle-mark-mode`; `q` (or any other non-shortcut command) to exit.  If you'd prefer speedrect commands not to continue in this way, set `speedrect-continue=nil`.\n\n\nNote that as mentioned many commands can be modified with a prefix (e.g. `M-10 S-right` or `C-u k`).\n\n## Details and tips\n\n### What is a rectangle to Emacs?\n\nA rectangle is just a _region_ (point and mark), _specially interpreted_, with a few extra pieces of information to allow the corners of the rectangle to go where point cannot (inside tabs, beyond the ends of lines, etc.).  While marking rectangles, you can use `x` to cycle point among any of the rectangle's four corners.  This can be very helpful to make changes on the appropriate side.\n\n### Using Calc\n\n\u003e[!TIP]\n\u003e Use `calc`, it's super-powerful...\n\n[`Calc`](https://www.gnu.org/software/emacs/manual/html_mono/calc.html) is an ancient and powerful calculator in emacs with many capabilities, including operating on [matrix data](https://www.gnu.org/software/emacs/manual/html_node/calc/Matrix-Tutorial.html).  In addition to simple sums, `speedRect` offers powerful _two-way_ communication with `calc` for sending in and yanking out columns of numerical data:\n\n1. It can send columns of numbers to calc as a _matrix_ (2D array of numbers).  Once in `calc`, you can operate on those numbers using a wide array of operations.  Many things \"just work\" on matrices (e.g. `1 +` will add one to all the numbers).  Others can easily be mapped over matrix elements (e.g. try `v M Q` to map `sqrt` over all elements). You can combine columns, change their order, transpose matrices, add them, and _much_ more.\n2. Once you have something you're happy with at the top of `calc`'s *stack* (which shows up at the bottom of the `*Calculator*` buffer, entry numbered `1:`), you can:\n    - hit `q` (or other window navigation) to return to your original buffer (where `rectangle-mark-mode` will still be active),\n    - adjust the position of your rectangle if needed (`S-left/right` and/or `x` is useful for this; a zero-width rectangle is fine), and\n    - hit `m` to yank the latest matrix from the `calc` stack into the buffer, replacing the marked rectangle.\n\nYou don't have to be in the same `rectangle-mark-mode` session you sent data from to yank a matrix from `calc`.  As long as the height of your rectangle matches the number of matrix rows, it will just work (and even if not, you'll just get a warning).  So you can start in one buffer, accumulate a matrix, manipulate it, switch to another buffer, and yank it there.\n\n\u003e [!NOTE]\n\u003e What you see is what you get in `calc`.  The numbers shown in `calc` will be yanked _as they appear_ on the stack, except `speedrect` automatically omits brackets and expands any `...` vector shortening enabled.  `v ,` will remove commas for a cleaner appearance.  `v \u003e` will right align numbers.  `d f` will let you set the number of digits after the decimal.  And _many_ more numerical formatting options. \n\n### Filling text within rectangles\n\nThere are several ways to \"fill\" content within a rectangle:\n\n1. `f`: if the marked rectangle is entirely blank, use the last killed rectangle's contents, filling to the width of the marked rectangle.\n1. `f`: if the marked rectangle is _not_ blank, use _its_ contents, filling to the width of the rectangle.\n1. `C-u f` or `M-N f` (where `N` is the number of chars wide): use the contents of either the last killed rectangle or the currently marked rectangle to fill to the specified width.\n1. `F`: same as above, except use the currently copied text on the kill ring as the text to fill.  \n\nOption 1 `f` is very useful if you want to fill in two steps:\n\n1. Mark a rectangular chunk of text and kill it (`k` or `C-u k`, to leave the space it occupies intact), and then\n2. Mark out a blank region and fill the prior rectangle's text there.\n\nOption 4. `F` is useful if you want to:\n\n1. Quickly kill some text in a buffer the normal way, e.g. `C-w`, or even take from the system clipboard, then\n2. Fill that text directly into a marked rectangle.  The contents of the marked rectangle are always replaced (whether blank or not).\n\nFor Option 2 `f`, if you want to _reduce_ the width of an existing filled rectangle, use a prefix to specify it numerically.\n\n\u003e[!NOTE]\n\u003eWhen filling rectangle, the _height_ of the rectangle marked for filling is significant.  It indicates to `speedrect` that the fill box can safely extend that far down without disturbing other rows of data.  It's normal to mark the full range down to the next row.  If more rows are needed, `speedrect` will add blank lines below to avoid disturbing subsequent rows of data.\n\n\n\n## Commands\n\nCurrent single keystroke bindings (available from `?`):\n\n```\nSpeedRect Rectangle Mark Mode Commands\n============================================================================\n\nInsertion:\n\n  [o] open      open rectangle with tabs/spaces, shifting text right\n  [t] string    replace rectangle with string\n  \nKilling:\n\n  [k] kill      kill and save rectangle for yanking (keep space, with prefix)\n  [d] delete    kill rectangle without saving\n  [SPC] del-ws  delete all whitespace from left (right, with prefix)\n  [c] clear     clear rectangle area by overwriting with spaces\n  [r] rest      delete the rest of the columns, keeping the marked rectangle\n  \nCopy/Yank:\n\n  [w] copy      copy rectangle for future rectangle yanking\n  [W] copy-text copy rectangle to kill ring as normal lines of text\n  [y] yank      yank rectangle, inserting at point\n  \nShift Rectangle (can use numeric prefixes):\n\n  [S-left]      move the rectangle left\n  [S-right]     move the rectangle right\n  [S-up]        move the rectangle up\n  [S-down]      move the rectangle down\n  [M-S-left]    move the rectangle left 5 columns\n  [M-S-right]   move the rectangle right 5 columns\n  [M-S-up]      move the rectangle up 5 lines\n  [M-S-down]    move the rectangle down 5 lines\n  \nChange Rectangle:\n\n  [x] corners   move point around corners of the rectangle\n  [n] new       start a new rectangle from this location\n  [l] last      restore the last used rectangle, if possible\n  \nNumerical:\n\n  [N] numbers   fill the rectangle with numeric range (prefix to set start)\n  [+/=] increment increment the first number (prefix to set increment)\n  [-] decrement decrement the first number (prefix to set decrement)\n  [#] grab      grab the rectangle as a matrix in calc\n  [_] across    sum across rows and grab result in calc as a vector\n  [:] down      sum down the columns and grab result in calc\n  [m] yank-mat  yank matrix from top of calc stack, overwriting selection\n  \nEtc:\n\n  [f] fill      fill text within rectangle (prefix to prompt fill width)\n  [M] multiple-cursors  add cursors at current column\n  [u] undo      undo last edit (and restart)\n  [?] help      view this Help buffer\n  [q] quit      exit rectangle-mark-mode\n```\n\n## Related packages\n\n- [phi-rectangle](https://github.com/zk-phi/phi-rectangle)\n- [cua-rectangle-mark-mode](https://www.gnu.org/software/emacs/manual/html_node/emacs/CUA-Bindings.html)\n\n## Thanks\n Contributors of ideas from [this discussion](https://www.reddit.com/r/emacs/comments/11k9u73/a_tiny_modal_rectanglemarkmode/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdtsmith%2Fspeedrect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdtsmith%2Fspeedrect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdtsmith%2Fspeedrect/lists"}