forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotion.vim
More file actions
61 lines (50 loc) · 1.59 KB
/
motion.vim
File metadata and controls
61 lines (50 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
" Python-mode motion functions
fun! pymode#motion#move(pattern, flags, ...) "{{{
let cnt = v:count1 - 1
let [line, column] = searchpos(a:pattern, a:flags . 'sW')
let indent = indent(line)
while cnt && line
let [line, column] = searchpos(a:pattern, a:flags . 'W')
if indent(line) == indent
let cnt = cnt - 1
endif
endwhile
return [line, column]
endfunction "}}}
fun! pymode#motion#vmove(pattern, flags) range "{{{
call cursor(a:lastline, 0)
let end = pymode#motion#move(a:pattern, a:flags)
call cursor(a:firstline, 0)
normal! v
call cursor(end)
endfunction "}}}
fun! pymode#motion#pos_le(pos1, pos2) "{{{
return ((a:pos1[0] < a:pos2[0]) || (a:pos1[0] == a:pos2[0] && a:pos1[1] <= a:pos2[1]))
endfunction "}}}
fun! pymode#motion#select(pattern, inner) "{{{
let cnt = v:count1 - 1
let orig = getpos('.')[1:2]
let snum = pymode#BlockStart(orig[0], a:pattern)
if getline(snum) !~ a:pattern
return 0
endif
let enum = pymode#BlockEnd(snum, indent(snum))
while cnt
let lnum = search(a:pattern, 'nW')
if lnum
let enum = pymode#BlockEnd(lnum, indent(lnum))
call cursor(enum, 1)
endif
let cnt = cnt - 1
endwhile
if pymode#motion#pos_le([snum, 0], orig) && pymode#motion#pos_le(orig, [enum, 1])
if a:inner
let snum = snum + 1
let enum = prevnonblank(enum)
endif
call cursor(snum, 1)
normal! v
call cursor(enum, len(getline(enum)))
endif
endfunction "}}}
" vim: fdm=marker:fdl=0