├── VimFlavor
├── doc
└── textobj-lastpat.txt
└── plugin
└── textobj
└── lastpat.vim
/VimFlavor:
--------------------------------------------------------------------------------
1 | flavor 'kana/vim-textobj-user', '~> 0.3'
2 |
--------------------------------------------------------------------------------
/doc/textobj-lastpat.txt:
--------------------------------------------------------------------------------
1 | *textobj-lastpat.txt* Text objects for the last searched pattern
2 |
3 | Version 0.0.2
4 | Script ID: 2355
5 | Copyright (C) 2008-2013 Kana Natsuno
6 | License: So-called MIT license {{{
7 | Permission is hereby granted, free of charge, to any person obtaining
8 | a copy of this software and associated documentation files (the
9 | "Software"), to deal in the Software without restriction, including
10 | without limitation the rights to use, copy, modify, merge, publish,
11 | distribute, sublicense, and/or sell copies of the Software, and to
12 | permit persons to whom the Software is furnished to do so, subject to
13 | the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included
16 | in all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | }}}
26 |
27 | CONTENTS *textobj-lastpat-contents*
28 |
29 | Introduction |textobj-lastpat-introduction|
30 | Interface |textobj-lastpat-interface|
31 | Commands |textobj-lastpat-commands|
32 | Functions |textobj-lastpat-functions|
33 | Mappings |textobj-lastpat-mappings|
34 | Bugs |textobj-lastpat-bugs|
35 | Changelog |textobj-lastpat-changelog|
36 |
37 |
38 |
39 |
40 | ==============================================================================
41 | INTRODUCTION *textobj-lastpat-introduction*
42 |
43 | *textobj-lastpat* is a Vim plugin to provide text objects to select an area
44 | which is matched to |last-pattern|.
45 |
46 |
47 | Requirements:
48 | - Vim 7.2 or later
49 | - |textobj-user| 0.3.5 or later (vimscript#2100)
50 |
51 | Installation:
52 | - Recommended way: Use vim-flavor .
53 |
54 | Latest version:
55 | https://github.com/kana/vim-textobj-lastpat
56 |
57 | Document in HTML format:
58 | http://vim-doc.heroku.com/view?https://github.com/kana/vim-textobj-lastpat/blob/master/doc/textobj-lastpat.txt
59 |
60 |
61 |
62 |
63 | ==============================================================================
64 | INTERFACE *textobj-lastpat-interface*
65 |
66 | ------------------------------------------------------------------------------
67 | MAPPINGS *textobj-lastpat-mappings*
68 |
69 | (textobj-lastpat-n) *(textobj-lastpat-n)*
70 | Select the first area which is matched to the
71 | |last-pattern|. The direction to search is the same
72 | as |n|.
73 |
74 | (textobj-lastpat-N) *(textobj-lastpat-N)*
75 | Like |(textobj-lastpat-n|, but the direction to
76 | search is the same as |N|.
77 |
78 |
79 |
80 |
81 | ==============================================================================
82 | CUSTOMIZING *textobj-lastpat-customizing*
83 |
84 | *g:textobj_lastpat_no_default_key_mappings*
85 | *:TextobjLastpatDefaultKeyMappings*
86 | This plugin will define the following key mappings in Visual mode and
87 | Operator-pending mode automatically. If you don't want these key mappings,
88 | define |g:textobj_lastpat_no_default_key_mappings| before this plugin is
89 | loaded (e.g. in your |vimrc|). You can also use
90 | |:TextobjLastpatDefaultKeyMappings| to redefine these key mappings. This
91 | command doesn't override existing {lhs}s unless [!] is given.
92 |
93 | {lhs} {rhs} ~
94 | ----- --------------------------- ~
95 | a/ (textobj-lastpat-n)
96 | i/ (textobj-lastpat-n)
97 | a? (textobj-lastpat-N)
98 | i? (textobj-lastpat-N)
99 |
100 |
101 |
102 |
103 | ==============================================================================
104 | BUGS *textobj-lastpat-bugs*
105 |
106 | - [count] is just ignored. It may be useful to select some area like |aw| or
107 | |iw| with [count].
108 |
109 | - See |textobj-user-bugs| for further information.
110 |
111 |
112 |
113 |
114 | ==============================================================================
115 | CHANGELOG *textobj-lastpat-changelog*
116 |
117 | 0.0.2 2013-01-18T20:58:48+09:00 *textobj-lastpat-changelog-0.0.2*
118 | - Support vim-flavor .
119 | - Update |textobj-lastpat-introduction|.
120 |
121 | 0.0.1 2012-03-24T14:51:08+09:00 *textobj-lastpat-changelog-0.0.1*
122 | - Refine the document a bit.
123 | - Refine the internal structure a bit.
124 |
125 | 0.0.0 2008-08-24T17:43:28+09:00 *textobj-lastpat-changelog-0.0.0*
126 | - Initial version.
127 |
128 |
129 |
130 |
131 | ==============================================================================
132 | vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker:
133 |
--------------------------------------------------------------------------------
/plugin/textobj/lastpat.vim:
--------------------------------------------------------------------------------
1 | " textobj-lastpat - Text objects for the last searched pattern
2 | " Version: 0.0.2
3 | " Copyright (C) 2008-2013 Kana Natsuno
4 | " License: So-called MIT 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_lastpat')
26 | finish
27 | endif
28 |
29 |
30 |
31 |
32 | call textobj#user#plugin('lastpat', {
33 | \ 'n': {
34 | \ 'select': ['a/', 'i/'],
35 | \ '*select-function*': 's:select_n',
36 | \ '*sfile*': expand('')
37 | \ },
38 | \ 'N': {
39 | \ 'select': ['a?', 'i?'],
40 | \ '*select-function*': 's:select_N',
41 | \ '*sfile*': expand('')
42 | \ },
43 | \ })
44 |
45 |
46 | function! s:select_n()
47 | return s:select(0)
48 | endfunction
49 |
50 | function! s:select_N()
51 | return s:select(1)
52 | endfunction
53 |
54 | function! s:select(opposite_p)
55 | let forward_p = (v:searchforward && !a:opposite_p)
56 | \ || (!v:searchforward && a:opposite_p)
57 |
58 | if search(@/, 'ce' . (forward_p ? '' : 'b')) == 0
59 | return 0
60 | endif
61 | let end_position = getpos('.')
62 |
63 | if search(@/, 'bc') == 0
64 | return 0
65 | endif
66 | let start_position = getpos('.')
67 |
68 | return ['v', start_position, end_position]
69 | endfunction
70 |
71 |
72 |
73 |
74 | let g:loaded_textobj_lastpat = 1
75 |
76 | " __END__
77 | " vim: foldmethod=marker
78 |
--------------------------------------------------------------------------------