{"id":16250832,"url":"https://github.com/selfint/code-blocks","last_synced_at":"2025-08-11T19:20:56.116Z","repository":{"id":65857304,"uuid":"599098853","full_name":"selfint/code-blocks","owner":"selfint","description":"Manipulate code as blocks","archived":false,"fork":false,"pushed_at":"2025-02-11T12:08:27.000Z","size":90629,"stargazers_count":6,"open_issues_count":16,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-29T06:04:48.954Z","etag":null,"topics":["rust","tree-sitter","typescript","vscode"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=selfint.code-blocks","language":"C","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/selfint.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-02-08T13:01:17.000Z","updated_at":"2025-03-25T11:49:13.000Z","dependencies_parsed_at":"2023-12-22T15:45:43.355Z","dependency_job_id":"c2629ebb-d0b2-481e-8813-310318178c75","html_url":"https://github.com/selfint/code-blocks","commit_stats":{"total_commits":152,"total_committers":2,"mean_commits":76.0,"dds":0.2828947368421053,"last_synced_commit":"4ccda774b668a734ee38a93e7214a9cefb048bfc"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/selfint/code-blocks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfint%2Fcode-blocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfint%2Fcode-blocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfint%2Fcode-blocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfint%2Fcode-blocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selfint","download_url":"https://codeload.github.com/selfint/code-blocks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfint%2Fcode-blocks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269941217,"owners_count":24500654,"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-08-11T02:00:10.019Z","response_time":75,"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":["rust","tree-sitter","typescript","vscode"],"created_at":"2024-10-10T15:06:48.329Z","updated_at":"2025-08-11T19:20:56.049Z","avatar_url":"https://github.com/selfint.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/selfint/code-blocks\"\u003e\n\u003cimg src=\"./assets/extension-logo.png\"alt=\"logo\" width='128'/\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://marketplace.visualstudio.com/items?itemName=selfint.code-blocks\" target=\"__blank\"\u003e\u003cimg src=\"https://img.shields.io/visual-studio-marketplace/v/selfint.code-blocks.svg?color=blue\u0026logo=visual-studio-code\" alt=\"Visual Studio Marketplace Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://marketplace.visualstudio.com/items?itemName=selfint.code-blocks\" target=\"__blank\"\u003e\u003cimg src=\"https://img.shields.io/visual-studio-marketplace/d/selfint.code-blocks.svg?color=4bdbe3\" alt=\"Visual Studio Marketplace Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://marketplace.visualstudio.com/items?itemName=selfint.code-blocks\" target=\"__blank\"\u003e\u003cimg src=\"https://img.shields.io/visual-studio-marketplace/i/selfint.code-blocks.svg?color=63ba83\" alt=\"Visual Studio Marketplace Installs\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/selfint/code-blocks/actions/workflows/ci-cd.yml\" target=\"__blank\"\u003e\u003cimg alt=\"GitHub CI\" src=\"https://img.shields.io/github/actions/workflow/status/selfint/code-blocks/ci-cd.yml\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/selfint/code-blocks\" target=\"__blank\"\u003e\u003cimg src=\"https://img.shields.io/github/last-commit/selfint/code-blocks.svg?color=24ba83\" alt=\"GitHub last commit\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/selfint/code-blocks/issues\" target=\"__blank\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/selfint/code-blocks.svg?color=orange\" alt=\"GitHub issues\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/selfint/code-blocks/stargazers\" target=\"__blank\"\u003e\u003cimg alt=\"GitHub stars\" src=\"https://img.shields.io/github/stars/selfint/code-blocks?style=social\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n\u003ch1\u003e\u003cp align=\"center\"\u003eCode blocks\u003c/p\u003e\u003c/h1\u003e\n\nSupercharge your editor with syntactically aware code navigation and manipulation, **_in any language_** supported by [tree-sitter](https://tree-sitter.github.io/tree-sitter/#parsers).\n\n## Features\n\n### Block mode\n\nSyntactically aware code selection (e.g. select scope), navigation (e.g. goto next function)\nand manipulation (e.g. re-order function parameters), right inside your editor.\n\n![rust_parameters_example](./assets/examples/Block_Mode_-_Move_-_Rust_-_Parameters.gif)\n\n### Code Blocks Editor\n\nBirds eye view over all your code blocks, with point and click refactoring.\n\n![svelte-1](./assets/editor/Code%20Blocks%20Demo%20-%20Editor%20-%20svelte%201.gif)\n\n### Tree viewer\n\nView your code's syntax tree directly\n\n![tree_viewer](./assets/examples/Tree_Viewer.gif)\n\n## Requirements\n\n-   `node` / `npm`: Used to download tree-sitter language parsers. Can be installed from [here](https://nodejs.org/en/download).\n\n-   **OPTIONAL:** `tree-sitter`: Used to for tree-sitter language parsers that need to be locally built.\n\n    After installing `npm`, can be installed by running:\n    `npm i -g tree-sitter-cli`.\n\n    If you don't want to install `tree-sitter`, there's a good chance you don't\n    need it. Try the extension without it, it will notify you if it's required.\n\n### Note\n\nThe extension **used** to require `emcc` (Emscripten compiler) or `docker` to compile tree-sitter parsers to WASM. **This is no longer required**.\n\n## Commands\n\n| Command                            | Usage                                                           |\n| ---------------------------------- | --------------------------------------------------------------- |\n| `codeBlocks.toggleActive`          | Toggle auto-parsing current file                                |\n| `codeBlocks.toggleBlockMode`       | Toggle Block Mode, will `toggleActive` if auto-parsing disabled |\n| `codeBlocks.toggleBlockModeColors` | Toggle Block Mode sibling/parent highlights                     |\n| `codeBlocks.open`                  | Reopen current file with Code Blocks editor                     |\n| `codeBlocks.openToTheSide`         | Open current file with Code Blocks editor on the side           |\n| `codeBlocks.openTreeViewer`        | View current file syntax tree                                   |\n| `codeBlocks.moveUp`                | Swap block with its previous sibling                            |\n| `codeBlocks.moveDown`              | Swap block with its next sibling                                |\n| `codeBlocks.navigateUp`            | Navigate to previous sibling                                    |\n| `codeBlocks.navigateDown`          | Navigate to next sibling                                        |\n| `codeBlocks.navigateUpForce`       | Navigate to parent start                                        |\n| `codeBlocks.navigateDownForce`     | Navigate to parent end                                          |\n| `codeBlocks.selectBlock`           | Expand selection to previous sibling                            |\n| `codeBlocks.selectPrevious`        | Expand selection to previous sibling                            |\n| `codeBlocks.selectNext`            | Expand selection to next sibling                                |\n| `codeBlocks.selectParent`          | Expand selection to parent                                      |\n| `codeBlocks.selectChild`           | Contract selection to first child                               |\n\n## Keybindings\n\nThese are the default key bindings, they are only active when \"block mode\" is active, and when the cursor is inside a text editor tab:\n\n| Command                        | Keybinding (cmd on mac) |\n| ------------------------------ | ----------------------- |\n| `codeBlocks.moveUp`            | `alt+left`              |\n| `codeBlocks.moveDown`          | `alt+right`             |\n| `codeBlocks.navigateUp`        | `ctrl/cmd+left`         |\n| `codeBlocks.navigateDown`      | `ctrl/cmd+right`        |\n| `codeBlocks.navigateUpForce`   | `ctrl/cmd+up`           |\n| `codeBlocks.navigateDownForce` | `ctrl/cmd+down`         |\n| `codeBlocks.selectBlock`       | -                       |\n| `codeBlocks.selectPrevious`    | `shift+left`            |\n| `codeBlocks.selectNext`        | `shift+right`           |\n| `codeBlocks.selectParent`      | `shift+up`              |\n| `codeBlocks.selectChild`       | `shift+down`            |\n\n## Configuration\n\n### Global\n\n-   `codeBlocks.treeSitterCliPath`: Path to the `tree-sitter` cli command. Defaults to `tree-sitter` (assumes command is in PATH).\n-   `codeBlocks.colors.enabled`: Whether Block Mode should color selections or not. Defaults to `false`.\n-   `codeBlocks.colors.sibling`: CSS string for sibling selection background color. Defaults to `var(--vscode-editor-selectionHighlightBackground)`.\n-   `codeBlocks.colors.parent`: CSS string for parent selection background color. Defaults to `var(--vscode-editor-linkedEditingBackground)`.\n-   `codeBlocks.ignoredLanguageIds`: Array of VScode [languageId](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers)s not to install/load parsers for.\n\n### Language specific (advanced)\n\nThese configurations are set at the [languageId](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers) level.\n\nMost languages should just work™, if you find a language that requires manual configuration please [create an issue](https://github.com/selfint/code-blocks/issues).\nOr [create a pull request](https://github.com/selfint/code-blocks/pulls) with your configuration added to the `configurationDefaults` section of the `package.json` file.\n\n-   `codeBlocks.npmPackageName`: [NPM](https://www.npmjs.com/) package name of the `tree-sitter` parser to use for the\n    language. Defaults to `tree-sitter-\u003clanguageId\u003e`, change if the package name doesn't match the languageId.\n\n-   `codeBlocks.parserName`: Filename of the WASM parser built by the `tree-sitter build --wasm` command, without the\n    `.wasm` extension. Defaults to `tree-sitter-\u003clanguageId\u003e`, change if the parser filename doesn't match the languageId.\n\n-   `codeBlocks.subdirectory`: Directory inside the NPM package containing the `tree-sitter` grammar. Defaults to the\n    root directory of the package, change if the grammar isn't there.\n\n-   `codeBlocks.queries`: Tree-sitter [queries](https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax)\n    to generate blocks, must contain at least one `@capture`. The name of the capture doesn't matter, the entire match will be a block.\n\n    Required by [Code Blocks Editor](#code-blocks-editor).\n\n    Optional for [Block Mode](#block-mode) - will auto-expand a selection if it is contained by a block.\n\n#### **Example configuration for `tsx`**\n\nLanguage ID: `typescriptreact`\n\nNPM package name: [tree-sitter-typescript](https://www.npmjs.com/package/tree-sitter-typescript)\n\nWASM parser name: `tree-sitter-ts.wasm`\n\nDesired blocks: JSX blocks, and documentation comments should be merged with documentees.\n\n```jsonc\n{\n    // language ID of .tsx files is 'typescriptreact'\n    \"[typescriptreact]\": {\n        // languageID != package name\n        \"codeBlocks.npmPackageName\": \"tree-sitter-typescript\",\n        // languageID != parser name\n        \"codeBlocks.parserName\": \"tree-sitter-tsx\",\n        // tree-sitter-typescript package contains a 'typescript' dir and a 'tsx' dir, so we need to specify 'tsx\n        \"codeBlocks.subdirectory\": \"tsx\",\n        \"codeBlocks.queries\": [\n            // group documentation comments with their documentees\n            \"( (comment)* @header . (class_declaration) @item)\",\n            \"( (comment)* @header . (method_definition) @item)\",\n            \"( (comment)* @header . (function_declaration) @item)\",\n            \"( (comment)* @header . (export_statement) @item)\",\n            // build blocks from jsx elements\n            \"(jsx_element) @item\",\n            \"(jsx_self_closing_element) @item\"\n        ]\n    }\n}\n```\n\n### Custom editors\n\n-   Code Blocks Editor (viewType `codeBlocks.editor`): UI for moving code blocks inside a file. Useful when refactoring large blocks over long distances.\n\n## Known Issues\n\n-   Out of bounds memory access ([#154](https://github.com/selfint/code-blocks/issues/154)): For now, reloading the editor fixes this.\n\n## License\n\nMIT License © 2023 [Tom Selfin](https://github.com/selfint)\n\n## Gallery\n\n### Block Mode - Move - Rust - Functions\n\n![Block Mode - Move - Rust - Functions](assets/examples/Block_Mode_-_Move_-_Rust_-_Functions.gif)\n\n### Block Mode - Move - Rust - Match arms\n\n![Block Mode - Move - Rust - Match arms](assets/examples/Block_Mode_-_Move_-_Rust_-_Match_arms.gif)\n\n### Block Mode - Move - Rust - Parameters\n\n![Block Mode - Move - Rust - Parameters](assets/examples/Block_Mode_-_Move_-_Rust_-_Parameters.gif)\n\n### Block Mode - Select - Rust\n\n![Block Mode - Select - Rust](assets/examples/Block_Mode_-_Select_-_Rust.gif)\n\n### Block Mode - Select - TypeScript\n\n![Block Mode - Select - TypeScript](assets/examples/Block_Mode_-_Select_-_TypeScript.gif)\n\n### Block Mode - Select - TypeScript - Selection expands to block\n\n![Block Mode - Select - TypeScript - Selection expands to block](assets/examples/Block_Mode_-_Select_-_TypeScript_-_Selection_expands_to_block.gif)\n\n### Tree Viewer\n\n![Tree Viewer](assets/examples/Tree_Viewer.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfint%2Fcode-blocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselfint%2Fcode-blocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfint%2Fcode-blocks/lists"}