├── README.md ├── doc └── textobj-space.txt └── plugin └── textobj └── space.vim /README.md: -------------------------------------------------------------------------------- 1 | vim-textobj-space 2 | ================= 3 | 4 | Text objects for continuity space 5 | 6 | Requirements 7 | ------------ 8 | 9 | [vim-textobj-user][1] 10 | 11 | usage 12 | ----- 13 | 14 | Keymap|target 15 | ----|--- 16 | iS|continuation space characters 17 | aS|continuation space and multibyte space characters 18 | 19 | e.g. 20 | ---- 21 | 22 | ```java 23 | /** 24 | * description of method 25 | * 26 | * @param int hoge description of hoge 27 | * @param int fuga description of fuga 28 | ^ 29 | */ 30 | ``` 31 | 32 | Cursor in the place of ^. 33 | 34 | ``` 35 | ciS 36 | ``` 37 | 38 | ```java 39 | /** 40 | * description of method 41 | * 42 | * @param int hoge description of hoge 43 | * @param int fuga description of fuga 44 | */ 45 | ``` 46 | 47 | [1]: https://github.com/kana/vim-textobj-user 48 | -------------------------------------------------------------------------------- /doc/textobj-space.txt: -------------------------------------------------------------------------------- 1 | *textobj-space.txt* Text objects for continuity space. 2 | 3 | Version: 0.0.3 4 | Author : saihoooooooo 5 | License: So-called MIT/X license {{{ 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | }}} 25 | 26 | ============================================================================== 27 | CONTENTS *textobj-space-contents* 28 | 29 | INTRODUCTION |textobj-space-introduction| 30 | INTERFACE |textobj-space-interface| 31 | KEY MAPPINGS |textobj-space-key-mappings| 32 | CUSTOMIZING |textobj-space-customizing| 33 | CHANGELOG |textobj-space-changelog| 34 | 35 | 36 | ============================================================================== 37 | INTRODUCTION *textobj-space-introduction* 38 | 39 | *textobj-space* is a Vim plugin to provide text objects to select continuity 40 | space character. 41 | 42 | Requirements: 43 | - Vim 7.0 or later 44 | - |textobj-user| 0.3.10 or later 45 | 46 | 47 | Latest version: 48 | https://github.com/saihoooooooo/vim-textobj-space 49 | 50 | ============================================================================== 51 | INTERFACE *textobj-space-interface* 52 | 53 | ------------------------------------------------------------------------------ 54 | KEY MAPPINGS *textobj-space-key-mappings* 55 | 56 | These key mappings are defined in Visual mode and Operator-pending mode. 57 | 58 | (textobj-space-a) *(textobj-space-a)* 59 | Select the continuity space, tab and multibyte space 60 | character from current position or next position. 61 | 62 | (textobj-space-i) *(textobj-space-i)* 63 | Select the continuity space character from current 64 | position or next position. 65 | 66 | ============================================================================== 67 | CUSTOMIZING *textobj-space-customizing* 68 | 69 | *g:textobj_space_no_default_key_mappings* 70 | *:TextobjSpaceDefaultKeyMappings* 71 | This plugin will define the following key mappings in Visual mode and 72 | Operator-pending mode automatically. If you don't want these key mappings, 73 | define |g:textobj_space_no_default_key_mappings| before this plugin is loaded 74 | (e.g. in your |vimrc|). You can also use |:TextobjSpaceDefaultKeyMappings| 75 | to redefine these key mappings. This command doesn't override existing {lhs}s 76 | unless [!] is given. 77 | 78 | {lhs} {rhs} ~ 79 | ----- --------------------------- ~ 80 | aS (textobj-space-a) 81 | iS (textobj-space-i) 82 | 83 | ============================================================================== 84 | CHANGELOG *textobj-space-changelog* 85 | 86 | 0.0.3 2012-10-06 87 | - Distribute behavior of 'aS' and 'iS'. 88 | 89 | 0.0.2 2012-02-10 90 | - Change default keymap, as/is -> aS/iS 91 | 92 | 0.0.1 2011-12-08 93 | - If there is no space at the cursor position, then find the next 94 | 95 | 0.0.0 2011-11-20 96 | - Initial version. 97 | 98 | ============================================================================== 99 | vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker: 100 | -------------------------------------------------------------------------------- /plugin/textobj/space.vim: -------------------------------------------------------------------------------- 1 | " textobj-space - Text objects for continuity space. 2 | " Version: 0.0.3 3 | " Author : saihoooooooo 4 | " License: So-called MIT/X license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | 25 | if exists('g:loaded_textobj_space') 26 | finish 27 | endif 28 | let g:loaded_textobj_space = 1 29 | let s:save_cpo = &cpo 30 | set cpo&vim 31 | 32 | call textobj#user#plugin('space', { 33 | \ '-': { 34 | \ '*sfile*': expand(':p'), 35 | \ 'select-a': 'aS', '*select-a-function*': 's:select_a', 36 | \ 'select-i': 'iS', '*select-i-function*': 's:select_i', 37 | \ } 38 | \ }) 39 | 40 | let s:pattern_a = '[[:blank:] ]\+' 41 | let s:pattern_i = ' \+' 42 | 43 | function! s:select_a() 44 | return s:select(s:pattern_a) 45 | endfunction 46 | 47 | function! s:select_i() 48 | return s:select(s:pattern_i) 49 | endfunction 50 | 51 | function! s:select(pattern) 52 | if matchstr(getline('.'), '.', col('.') - 1) !~ a:pattern 53 | call search(a:pattern) 54 | if matchstr(getline('.'), '.', col('.') - 1) !~ a:pattern 55 | return 56 | endif 57 | endif 58 | 59 | call search(a:pattern, 'bc') 60 | let start = getpos('.') 61 | call search(a:pattern, 'ce') 62 | let end = getpos('.') 63 | return ['v', start, end] 64 | endfunction 65 | 66 | let &cpo = s:save_cpo 67 | unlet s:save_cpo 68 | --------------------------------------------------------------------------------