{"id":32388850,"url":"https://github.com/seasmith/alignassign","last_synced_at":"2025-10-25T03:56:12.188Z","repository":{"id":45234487,"uuid":"69917407","full_name":"seasmith/AlignAssign","owner":"seasmith","description":"Align the assignment operators within a highlighted area.","archived":false,"fork":false,"pushed_at":"2022-06-28T15:58:49.000Z","size":806,"stargazers_count":76,"open_issues_count":7,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T06:02:17.424Z","etag":null,"topics":["addin","r"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seasmith.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-03T22:50:04.000Z","updated_at":"2024-07-31T09:44:31.000Z","dependencies_parsed_at":"2022-08-04T13:00:13.237Z","dependency_job_id":null,"html_url":"https://github.com/seasmith/AlignAssign","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seasmith/AlignAssign","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2FAlignAssign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2FAlignAssign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2FAlignAssign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2FAlignAssign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seasmith","download_url":"https://codeload.github.com/seasmith/AlignAssign/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2FAlignAssign/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280901444,"owners_count":26410586,"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","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["addin","r"],"created_at":"2025-10-25T03:56:11.071Z","updated_at":"2025-10-25T03:56:12.181Z","avatar_url":"https://github.com/seasmith.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n# AlignAssign\n\n[![Build Status](https://travis-ci.org/seasmith/AlignAssign.svg?branch=master)](https://travis-ci.org/seasmith/AlignAssign)\n\nAlign the assignment operators (either `\u003c-` or `=`) within a highlighted area.\n\nBefore:\n```{r, eval=FALSE}\na \u003c- 1:5\nbbb \u003c- 6:10\nc \u003c- letters\n```\n\nAfter:\n```{r, eval=FALSE}\na   \u003c- 1:5\nbbb \u003c- 6:10\nc   \u003c- letters\n```\n\n![](inst/media/demo2.gif)\n\n#### Align Cursors\n\nFor alignment of any text, you can align multiple cursors with the **Align Cursors** addin.\nAdd multiple cursors to your document by holding \u003ckbd\u003eCtrl\u003c/kbd\u003e/\u003ckbd\u003eCmd\u003c/kbd\u003e + \u003ckbd\u003eAlt\u003c/kbd\u003e and clicking in the RStudio editor, or by holding \u003ckbd\u003eAlt\u003c/kbd\u003e and clicking and dragging the mouse.\n\n![](inst/media/demo_cursors.gif)\n\n### What\nAlignAssign contains three addins. Two addins align all of either the  `\u003c-` (`Align Assign`) or `=` (`Align Assign 2`) assignment operators within a highlighted region and the third aligns multiple cursors across lines to the same column. \n\nNone of the addins \"reflow\" your code if the alignment breaks the page width. They also does not treat commented lines differently to uncommented lines. __If there is either one of the assignment operators within a highlighted comment line, then it will either align that operator or align other operators to it.__\n\n## Install\n```{r install, eval=FALSE}\ndevtools::install_github(\"seasmith/AlignAssign\")`\n```\n\nYou can assign each alignment addin action to a specific keyboard shortcut in RStudio in the *Modify keyboard shortcuts...* menu option under the *Tools* menu.\n\n## Examples\n\n#### Align `\u003c-`'s with Align Assign\nWhen you highlight the following chunk of code (region) - whether you highlight the entirity or just a portion of the first and last lines - and then run the `Align Assign` addin...\n```{r, eval=FALSE}\n# This is a commented line\n# So is this\na \u003c- 1:5\nb \u003c- 6:10\ncopy_a \u003c- a\n# More comments\n```\n\n...the result will look like this.\n```{r, eval=FALSE}\n# This is a commented line\n# So is this\na      \u003c- 1:5\nb      \u003c- 6:10\ncopy_a \u003c- a\n# More comments\n```\n\n#### Align `=`'s with Align Assign 2\nThe above example also works for the `=` operator when using the other addin, `Align Assign 2`. Before...\n```{r, eval=FALSE}\n# Perosnal information\nlist(surname = \"Crichton\",\n     firstName = \"John\",\n     address = NA,\n     occupation = \"fugitive\")\n```\n\n...after.\n```{r, eval=FALSE}\n# Perosnal information\nlist(surname    = \"Crichton\",\n     firstName  = \"John\",\n     address    = NA,\n     occupation = \"fugitive\")\n```\n\n#### Behavior of commented-out assignment operators\nBe mindful that highling a chunk of code which has assignment operators within commented lines, like the following, and running the `Align Assign 2` addin...\n```{r, eval=FALSE}\n# This is a commented line with an assignment operator \u003c-\na \u003c- 1:5\nb \u003c- 6:10\nc \u003c- 11:15\n# There is an assignment operator \u003c- here, too\n```\n\n...will result in something like this.\n```{r, eval=FALSE}\n# This is a commented line with an assignment operator \u003c-\na                                                      \u003c- 1:5\nb                                                      \u003c- 6:10\nc                                                      \u003c- 11:15\n# There is an assignment operator                      \u003c- here, too\n```\n\n#### Not so smart aligner\nThere is also no special handling of assignment operators within a function. So, if you highlighted the entire chunk below and then ran the `Align Assign` addin...\n```{r, eval=FALSE}\nvar1 \u003c- letters\nvar2 \u003c- as.list(sample(1:26, 26))\nnames(var2) \u003c- var1[unlist(var2)]\nlist.pos \u003c- function(name, lst){\n    matches \u003c- sapply(name, function(x){\n        matched \u003c- which(names(lst) %in% x)\n\n        if(length(matched) == 0) matched \u003c- NA\n        matched\n    })\n    return(matches)\n}\npositions \u003c- list.pos(c(\"a\", \"bbb\", \"c\"), var2)\n```\n\n...the result will look like this.\n```{r, eval=FALSE}\nvar1                                     \u003c- letters\nvar2                                     \u003c- as.list(sample(1:26, 26))\nnames(var2)                              \u003c- var1[unlist(var2)]\nlist.pos                                 \u003c- function(name, lst){\n    matches                              \u003c- sapply(name, function(x){\n        matched                          \u003c- which(names(lst) %in% x)\n\n        if(length(matched) == 0) matched \u003c- NA\n        matched\n    })\n    return(matches)\n}\npositions                                \u003c- list.pos(c(\"a\", \"bbb\", \"c\"), var2)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseasmith%2Falignassign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseasmith%2Falignassign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseasmith%2Falignassign/lists"}