Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Distribute behavior of "aS" and "iS".
  • Loading branch information
saihoooooooo committed Oct 6, 2012
1 parent 973cbdb commit 04ff7b5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
15 changes: 11 additions & 4 deletions doc/textobj-space.txt
@@ -1,6 +1,6 @@
*textobj-space.txt* Text objects for continuity space.

Version: 0.0.2
Version: 0.0.3
Author : saihoooooooo <saihoooooooo@gmail.com>
License: So-called MIT/X license {{{
Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -55,7 +55,11 @@ KEY MAPPINGS *textobj-space-key-mappings*

These key mappings are defined in Visual mode and Operator-pending mode.

<Plug>(textobj-space) *<Plug>(textobj-space)*
<Plug>(textobj-space-a) *<Plug>(textobj-space-a)*
Select the continuity space, tab and multibyte space
character from current position or next position.

<Plug>(textobj-space-i) *<Plug>(textobj-space-i)*
Select the continuity space character from current
position or next position.

Expand All @@ -73,12 +77,15 @@ unless [!] is given.

{lhs} {rhs} ~
----- --------------------------- ~
aS <Plug>(textobj-space)
iS <Plug>(textobj-space)
aS <Plug>(textobj-space-a)
iS <Plug>(textobj-space-i)

==============================================================================
CHANGELOG *textobj-space-changelog*

0.0.3 2012-10-06
- Distribute behavior of 'aS' and 'iS'.

0.0.2 2012-02-10
- Change default keymap, as/is -> aS/iS

Expand Down
40 changes: 24 additions & 16 deletions plugin/textobj/space.vim
@@ -1,5 +1,5 @@
" textobj-space - Text objects for continuity space.
" Version: 0.0.1
" Version: 0.0.3
" Author : saihoooooooo <saihoooooooo@gmail.com>
" License: So-called MIT/X license {{{
" Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -30,27 +30,35 @@ let s:save_cpo = &cpo
set cpo&vim

call textobj#user#plugin('space', {
\ '-': {
\ 'select': ['aS', 'iS'],
\ '*select-function*': 's:select',
\ '*sfile*': expand('<sfile>')
\ }
\})

function! s:select()
return s:select()
\ '-': {
\ '*sfile*': expand('<sfile>:p'),
\ 'select-a': 'aS', '*select-a-function*': 's:select_a',
\ 'select-i': 'iS', '*select-i-function*': 's:select_i',
\ }
\ })

let s:pattern_a = '[[:blank:] ]\+'
let s:pattern_i = ' \+'

function! s:select_a()
return s:select(s:pattern_a)
endfunction

function! s:select()
if matchstr(getline('.'), '.', col('.')-1) !~ '[  \t]\+'
call search('[  \t]\+')
if matchstr(getline('.'), '.', col('.')-1) !~ '[  \t]\+'
function! s:select_i()
return s:select(s:pattern_i)
endfunction

function! s:select(pattern)
if matchstr(getline('.'), '.', col('.') - 1) !~ a:pattern
call search(a:pattern)
if matchstr(getline('.'), '.', col('.') - 1) !~ a:pattern
return
endif
endif
call search('[  \t]\+', 'bc')

call search(a:pattern, 'bc')
let start = getpos('.')
call search('[  \t]\+', 'ce')
call search(a:pattern, 'ce')
let end = getpos('.')
return ['v', start, end]
endfunction
Expand Down

0 comments on commit 04ff7b5

Please sign in to comment.