{"id":25096599,"url":"https://github.com/jceb/vim-textobj-uri","last_synced_at":"2025-04-02T02:14:19.418Z","repository":{"id":12515043,"uuid":"15184809","full_name":"jceb/vim-textobj-uri","owner":"jceb","description":"Text objects for dealing with URIs","archived":false,"fork":false,"pushed_at":"2024-08-01T09:39:16.000Z","size":26,"stargazers_count":36,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T21:02:22.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"forcedotcom/salesforce-deskcom-api","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jceb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-14T11:46:26.000Z","updated_at":"2024-08-01T09:39:19.000Z","dependencies_parsed_at":"2022-09-16T23:21:50.638Z","dependency_job_id":null,"html_url":"https://github.com/jceb/vim-textobj-uri","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jceb%2Fvim-textobj-uri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jceb%2Fvim-textobj-uri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jceb%2Fvim-textobj-uri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jceb%2Fvim-textobj-uri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jceb","download_url":"https://codeload.github.com/jceb/vim-textobj-uri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246741119,"owners_count":20826066,"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":"2025-02-07T16:49:05.829Z","updated_at":"2025-04-02T02:14:19.392Z","avatar_url":"https://github.com/jceb.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"vim-textobj-uri\n===============\n\nText objects for dealing with URIs and passing them on to other\nprograms/handlers.\n\n## Installation\nI recommend installing [pathogen.vim](https://github.com/tpope/vim-pathogen),\nand then execute the following commands:\n\n1. Install [vim-textobj-user](https://github.com/kana/vim-textobj-user)\n2. Install [vim-textobj-uri](https://github.com/jceb/vim-textobj-uri)\n\n     cd ~/.vim/bundle\n     git clone https://github.com/jceb/vim-textobj-uri.git\n\n## Usage\nOnce installed, vim-textobj-uri provides these text objects for dealing with\nURIs:\n- `au` refers to a whole URI including trailing spaces.  Example: `cau` changes\n  the URI the cursor is on, including trailing spaces\n- `iu` refers to a whole URI without trailing spaces.  Example: `ciu` changes\n  the URI the cursor is on without trailing spaces\n\nFor passing URIs to other programs or handlers, the `go` keybinding is provided.\nExample text in Vim:\n\n    some text http://www.|slashdot.org/ some more text\n\nThe cursor (`|`) is within the URI.  Typing `go` will open this URI in the\ndefault web browser on Linux systems.\n\n## Customization\nAll configuration is stored in global variables starting with `g:textobj_uri_`.\n\n### Add more patterns and handlers\nWith the following command custom patterns and handlers can be specified:\n\n    :URIPatternAdd \u003cPATTERN\u003e [\u003cHANDLER\u003e] [\u003cFILETYPE\u003e [\u003cFILETYPE\u003e]]\n\nDuring initialisation of vim the command `:URIPatternAdd` might not be\navailable, yet.  Another way to add a pattern is to use the following function\ncall:\n\n\t:call textobj#uri#add_pattern(\u003cCLEAR_PATTERNS\u003e, \u003cPATTERN\u003e, [\u003cHANDLER\u003e], [\u003cFILETYPE\u003e, [\u003cFILETYPE\u003e]])\n\nIntegration with other programs is done through a connection of a certain regex\npattern with a handler.  The handler is optional, it's only used by the `go`\nkeybinding.\n\nExample:\n\n    :URIPatternAdd spotify:[a-zA-Z0-9]\\\\+ :silent\\ !spotify-client\\ \"%s\"\n\nFor both, pattern and handler, spaces need to be escaped with backslash (`\\`).\nBy adding a bang (`!`) to the command all existing patterns are cleared and\nreplaced by the new pattern.\n\nThe pattern is `spotify:[a-zA-Z0-9]\\\\+`, it could be anything that should be a\nURI.\n\nThe handler is `:silent\\ !spotify-client\\ \"%s\"`.  Handlers are either vim\ncommands starting with a colon (`:`) or vim normal mode commands not starting\nwith colon.  If `%s` is present in the handler it will be replaced with URI.\nAttention, special characters will not be escaped!  In addition, `g:textobj_uri`\nwill be set to URI.  It might be safter to use the variable to access URI.\n\nIf the pattern contains a sub-expression than the match of the first\nsub-expression is returned as URI.  This makes it easy to take only a portion of\nthe URI for further processing.  Sub-expressions are enclosed by `\\(` and `\\)`.\nExample pattern:\n\n    spotify:\\\\([a-zA-Z0-9]\\\\+\\\\)\n\nThe pattern matches a spotify URI but only the portion after the colon is passed\non to the handler.\n\n\nIt is also possible to build sophisticated handlers that extract a portion of a\nURI to process it further.  E.g. this URI pattern handles bug references in the\nform of: Bug #1234.  It builds a new URL from a static string and the extracted\nbug id:\n\n    :URIPatternAdd Bug:\\\\?\\ #\\\\?[0-9]\\\\+ :exec\\ \":!silent\\ xdg-open\\ 'http://forge.univention.org/bugzilla/show_bug.cgi?id=\".substitute(\"%s\",\"^[bB]ug:\\\\\\\\?\\ #\\\\\\\\?\\\\\\\\([0-9]\\\\\\\\+\\\\\\\\)$\",\"\\\\\\\\1\",'').\"'\"\n\nThe above example can also be achieved using sub-expressions:\n\n    :URIPatternAdd Bug:\\\\?\\ #\\\\?\\\\([0-9]\\\\+\\\\) :silent\\ !xdg-open\\ 'http://forge.univention.org/bugzilla/show_bug.cgi?id=%s'\n\n### Add positioning patterns\nIn markup languages URIs consist of more than the plain URI.  In addition to the\nURI there is a special syntax for combining it with, i.e. a description.  To\nsupport also these types of URIs so called positioning patterns can be\nspecified.  These patterns contain the special vim-regex expression `\\zs` which\ndefines the position where the actual URI starts.  The cursor will be put at\nthis position and than the URI patterns are applied.\n\nThe following command specifies a positioning pattern:\n\n    :URIPositioningPatternAdd \u003cPATTERN\u003e [\u003cFILETYPE\u003e [\u003cFILETYPE\u003e]]\n\nDuring initialisation of vim the command `:URIPatternAdd` might not be\navailable, yet.  Another way to add a pattern is to use the following function\ncall:\n\n\t:call textobj#uri#add_positioning_pattern(\u003cCLEAR_PATTERNS\u003e, \u003cPATTERN\u003e, [\u003cFILETYPE\u003e, [\u003cFILETYPE\u003e]])\n\nExample:\n\n \t:URIPositioningPatternAdd \\[[^]]*\\](\\zs[^)]\\+) markdown\n\nThis is a link pattern in Markdown syntax.  The cursor can be anywhere on this\nlink, using the text objects or triggering the handler will move it to the URI\nand will work only on it.\n\n1. Initial text, cursor is represented by `|`:\n\n\n    some text \\[Link |description\\](http://www.slashdot.org/)\n\n2. Text after changing the URI by typing `ciu`:\n\n\n    some text \\[Link description\\](|)\n\n## TODO\n- add text objects that match till the start and end of a URI\n- add command URIOpen that takes a URI and opens it with the appropriate handler\n- add mapping to run URIOpen on a visual mode selection\n- add more file type specific positioning patterns\n\n## License\nMIT License, see LICENSE file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjceb%2Fvim-textobj-uri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjceb%2Fvim-textobj-uri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjceb%2Fvim-textobj-uri/lists"}