{"id":13545617,"url":"https://github.com/kana/vim-textobj-user","last_synced_at":"2025-05-16T11:05:16.827Z","repository":{"id":41384275,"uuid":"575670","full_name":"kana/vim-textobj-user","owner":"kana","description":"Vim plugin: Create your own text objects","archived":false,"fork":false,"pushed_at":"2020-02-21T09:29:25.000Z","size":223,"stargazers_count":1459,"open_issues_count":22,"forks_count":47,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-09T07:01:48.055Z","etag":null,"topics":["vim","vim-plugins","vim-textobj-user"],"latest_commit_sha":null,"homepage":"http://www.vim.org/scripts/script.php?script_id=2100","language":"Vim script","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/kana.png","metadata":{"files":{"readme":"README.md","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":"2010-03-23T13:46:01.000Z","updated_at":"2025-04-06T02:11:55.000Z","dependencies_parsed_at":"2022-09-12T03:21:15.608Z","dependency_job_id":null,"html_url":"https://github.com/kana/vim-textobj-user","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kana%2Fvim-textobj-user","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kana%2Fvim-textobj-user/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kana%2Fvim-textobj-user/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kana%2Fvim-textobj-user/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kana","download_url":"https://codeload.github.com/kana/vim-textobj-user/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"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":["vim","vim-plugins","vim-textobj-user"],"created_at":"2024-08-01T11:01:07.173Z","updated_at":"2025-05-16T11:05:11.819Z","avatar_url":"https://github.com/kana.png","language":"Vim script","readme":"# vim-textobj-user - Create your own text objects\n\n[![Build Status](https://travis-ci.org/kana/vim-textobj-user.png)](https://travis-ci.org/kana/vim-textobj-user)\n\nvim-textobj-user is a Vim plugin to create your own text objects without pain.\nIt is hard to create text objects, because there are many pitfalls to deal\nwith.  This plugin hides such details and provides a declarative way to define\ntext objects.  You can use regular expressions to define simple text objects,\nor use functions to define complex ones.\n\n\n\n\n## Examples\n\n### Simple text objects defined by a pattern\n\nDefine `ad`/`id` to select a date such as `2013-03-16`, and\ndefine `at`/`it` to select a time such as `22:04:21`:\n\n```vim\ncall textobj#user#plugin('datetime', {\n\\   'date': {\n\\     'pattern': '\\\u003c\\d\\d\\d\\d-\\d\\d-\\d\\d\\\u003e',\n\\     'select': ['ad', 'id'],\n\\   },\n\\   'time': {\n\\     'pattern': '\\\u003c\\d\\d:\\d\\d:\\d\\d\\\u003e',\n\\     'select': ['at', 'it'],\n\\   },\n\\ })\n```\n\n\n### Simple text objects surrounded by a pair of patterns\n\nDefine `aA` to select text from `\u003c\u003c` to the matching `\u003e\u003e`, and\ndefine `iA` to select text inside `\u003c\u003c` and `\u003e\u003e`:\n\n```vim\ncall textobj#user#plugin('braces', {\n\\   'angle': {\n\\     'pattern': ['\u003c\u003c', '\u003e\u003e'],\n\\     'select-a': 'aA',\n\\     'select-i': 'iA',\n\\   },\n\\ })\n```\n\n\n### Complex text objects defined by functions\n\nDefine `al` to select the current line, and\ndefine `il` to select the current line without indentation:\n\n```vim\ncall textobj#user#plugin('line', {\n\\   '-': {\n\\     'select-a-function': 'CurrentLineA',\n\\     'select-a': 'al',\n\\     'select-i-function': 'CurrentLineI',\n\\     'select-i': 'il',\n\\   },\n\\ })\n\nfunction! CurrentLineA()\n  normal! 0\n  let head_pos = getpos('.')\n  normal! $\n  let tail_pos = getpos('.')\n  return ['v', head_pos, tail_pos]\nendfunction\n\nfunction! CurrentLineI()\n  normal! ^\n  let head_pos = getpos('.')\n  normal! g_\n  let tail_pos = getpos('.')\n  let non_blank_char_exists_p = getline('.')[head_pos[2] - 1] !~# '\\s'\n  return\n  \\ non_blank_char_exists_p\n  \\ ? ['v', head_pos, tail_pos]\n  \\ : 0\nendfunction\n```\n\n\n### Text objects for a specific filetype\n\nDefine `a(` to select text from `\\left(` to the matching `\\right)`, and\ndefine `i(` to select text inside `\\left(` to the matching `\\right)`,\nbut *only for tex files*:\n\n```vim\ncall textobj#user#plugin('tex', {\n\\   'paren-math': {\n\\     'pattern': ['\\\\left(', '\\\\right)'],\n\\     'select-a': [],\n\\     'select-i': [],\n\\   },\n\\ })\n\naugroup tex_textobjs\n  autocmd!\n  autocmd FileType tex call textobj#user#map('tex', {\n  \\   'paren-math': {\n  \\     'select-a': '\u003cbuffer\u003e a(',\n  \\     'select-i': '\u003cbuffer\u003e i(',\n  \\   },\n  \\ })\naugroup END\n```\n\n\n\n\n## Further reading\n\nYou can define your own text objects like the above examples.  See also\n[the reference manual](https://github.com/kana/vim-textobj-user/blob/master/doc/textobj-user.txt)\nfor more details.\n\nThere are many text objects written with vim-textobj-user.\nIf you want to find useful ones, or to know how they are implemented,\nsee [a list of text objects implemented with\nvim-textobj-user](https://github.com/kana/vim-textobj-user/wiki).\n\n\n\n\n\u003c!-- vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=78 : --\u003e\n","funding_links":[],"categories":["Vim Script","Tools"],"sub_categories":["Editing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkana%2Fvim-textobj-user","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkana%2Fvim-textobj-user","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkana%2Fvim-textobj-user/lists"}