@@ -3,82 +3,9 @@ if exists('g:loaded_textobj_underscore')
3
3
endif
4
4
5
5
call textobj#user#plugin (' underscore' , {
6
- \ ' a' : { ' sfile ' : expand ( ' <sfile> ' ), ' select' : ' a_' , ' select-function' : ' s: select_a' },
7
- \ ' A' : { ' sfile ' : expand ( ' <sfile> ' ), ' select' : ' a-' , ' select-function' : ' s: select_A' },
8
- \ ' i' : { ' sfile ' : expand ( ' <sfile> ' ), ' select' : ' i_' , ' select-function' : ' s: select_i' },
6
+ \ ' a' : { ' select' : ' a_' , ' select-function' : ' textobj#underscore# select_a' },
7
+ \ ' A' : { ' select' : ' a-' , ' select-function' : ' textobj#underscore# select_A' },
8
+ \ ' i' : { ' select' : ' i_' , ' select-function' : ' textobj#underscore# select_i' },
9
9
\ })
10
10
11
- function ! s: search_underscore ()
12
- let current_pos = getpos (' .' )
13
- let start_pos = searchpos (' _' , ' bcn' , current_pos[1 ])
14
- if start_pos == [0 , 0 ]
15
- throw ' not_found'
16
- else
17
- let end_pos = searchpos (' _' , ' n' , current_pos[1 ])
18
- if end_pos == [0 , 0 ]
19
- if current_pos[1 :2 ] == start_pos
20
- let end_pos = start_pos
21
- let start_pos = searchpos (' _' , ' bn' , current_pos[1 ])
22
- if start_pos == [0 , 0 ]
23
- throw ' not_found'
24
- endif
25
- else
26
- throw ' not_found'
27
- endif
28
- endif
29
- endif
30
-
31
- return [ start_pos[1 ], end_pos[1 ] ]
32
- endfunction
33
-
34
- function ! s: select_a ()
35
- try
36
- let [ start_col, end_col ] = s: search_underscore ()
37
- catch
38
- return 0
39
- endtry
40
-
41
- let start_pos = getpos (' .' )
42
- let start_pos[2 ] = start_col
43
-
44
- let end_pos = getpos (' .' )
45
- let end_pos[2 ] = end_col
46
-
47
- return [ ' v' , start_pos, end_pos ]
48
- endfunction
49
-
50
- function ! s: select_A ()
51
- try
52
- let [ start_col, end_col ] = s: search_underscore ()
53
- catch
54
- return 0
55
- endtry
56
-
57
- let start_pos = getpos (' .' )
58
- let start_pos[2 ] = start_col + 1
59
-
60
- let end_pos = getpos (' .' )
61
- let end_pos[2 ] = end_col
62
-
63
- return [ ' v' , start_pos, end_pos ]
64
- endfunction
65
-
66
- " ciao_come_stai
67
-
68
- function ! s: select_i ()
69
- try
70
- let [ start_col, end_col ] = s: search_underscore ()
71
- catch
72
- return 0
73
- endtry
74
-
75
- let start_pos = getpos (' .' )
76
- let start_pos[2 ] = start_col + 1
77
-
78
- let end_pos = getpos (' .' )
79
- let end_pos[2 ] = end_col - 1
80
-
81
- return [' v' , start_pos, end_pos]
82
- endfunction
83
-
84
11
let g: loaded_textobj_underscore = 1
0 commit comments