From db886704bd7410e11215fc8dbb0c516e6ac2eafa Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 8 Mar 2018 23:21:09 -0500 Subject: docs --- LICENSE | 19 +++++++++++++++++++ README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ doc/textobj.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 doc/textobj.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d59eb6e --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright 2018 Jesse Luehrs + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3c2042 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Overview + +This plugin allows configuration of custom text objects, to perform actions on +additional sections of text than Vim has built-in. + +# Installation + +This plugin can be installed as a standard Vim package (see `:help packages`). +Simply clone this repository into ~/.vim/pack/plugins/start/vim-textobj to +install the Vim files for this plugin. + +# Configuration + +Configuration is done by setting the `g:textobj_defs` variable to a dict which +maps input keys to a list containing the text object type and arguments to pass +to that type. For instance: + +``` + let g:textobj_defs = { + \ '/': ['paired'], + \ 'r': ['paired', '/'], + \ '\|': ['paired'], + \ 'f': ['fold'], + \ ',': ['arg'], + \} +``` + +This defines five text object characters: `/` and `r` (for regex?) for text +within matching pairs of `/` characters, `|` for text within matching pairs of +`|` characters, `f` for text within the current fold, and `,` for the current +argument in a comma-separated function argument list. This, for instance, +allows you to use `di/` to delete the text within a Perl regex. + +Currently, these are the available types: + +* `paired`: matches text between pairs of characters. Takes one optional + argument for the character to match between, which defaults to the input + character. + +* `fold`: matches the text within the current fold. Takes no arguments. + +* `arg`: matches the current function argument. Given text like + `foo(bar, b|az, quux)` (where `|` is the cursor location), if `,` is the + input character, `da,` will result in `foo(bar, |quux)` and `di,` will + result in `foo(bar, |, quux)` . Takes no arguments. diff --git a/doc/textobj.txt b/doc/textobj.txt new file mode 100644 index 0000000..fdd035f --- /dev/null +++ b/doc/textobj.txt @@ -0,0 +1,51 @@ +*textobj.txt* Allows configuration of custom text objects + +Author: Jesse Luehrs +License: MIT + +============================================================================= +OVERVIEW *textobj-overview* + +This plugin allows configuration of custom |text-objects|, to perform actions +on additional sections of text than Vim has built-in. + +============================================================================= +CONFIGURATION *textobj-configuration* + +Configuration is done by setting the `g:textobj_defs` variable to a |dict| +which maps input keys to a list containing the text object type and arguments +to pass to that type. For instance: + +> + let g:textobj_defs = { + \ '/': ['paired'], + \ 'r': ['paired', '/'], + \ '\|': ['paired'], + \ 'f': ['fold'], + \ ',': ['arg'], + \} +< + +This defines five text object characters: `/` and `r` (for regex?) for text +within matching pairs of `/` characters, `|` for text within matching pairs of +`|` characters, `f` for text within the current fold, and `,` for the current +argument in a comma-separated function argument list. This, for instance, +allows you to use `di/` to delete the text within a Perl regex. + +Currently, these are the available types: + + *textobj-paired* +* `paired`: matches text between pairs of characters. Takes one optional + argument for the character to match between, which defaults to the input + character. + + *textobj-fold* +* `fold`: matches the text within the current fold. Takes no arguments. + + *textobj-arg* +* `arg`: matches the current function argument. Given text like + `foo(bar, b|az, quux)` (where `|` is the cursor location), if `,` is the + input character, `da,` will result in `foo(bar, |quux)` and `di,` will + result in `foo(bar, |, quux)` . Takes no arguments. + + vim:tw=78:et:ft=help:norl: -- cgit v1.2.3