moveNextPrev

This commit is contained in:
mattn
2012-05-31 17:47:14 +09:00
parent 06dd83dad3
commit 7fe889d214
5 changed files with 80 additions and 14 deletions

View File

@@ -131,3 +131,13 @@ function! zencoding#lang#css#balanceTag(flag) range
call setpos('.', curpos)
endif
endfunction
function! zencoding#lang#css#moveNextPrev(flag)
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
if pos == 2
startinsert!
else
silent! normal! l
startinsert
endif
endfunction

View File

@@ -125,4 +125,40 @@ function! zencoding#lang#haml#toggleComment()
endfunction
function! zencoding#lang#haml#balanceTag(flag) range
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = getpos('.')
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
if l > 0 && l < ml
let ml = l
break
endif
let n -= 1
endwhile
let sn = n
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
break
endif
let n += 1
endwhile
call setpos('.', [0, sn, 1, 0])
normal! V
call setpos('.', [0, n, 1, 0])
endfunction
function! zencoding#lang#haml#moveNextPrev(flag)
let pos = search('""', a:flag ? 'Wb' : 'W')
if pos != 0
silent! normal! l
startinsert
endif
endfunction

View File

@@ -573,3 +573,13 @@ function! zencoding#lang#html#balanceTag(flag) range
call setpos('.', curpos)
endif
endfunction
function! zencoding#lang#html#moveNextPrev(flag)
let pos = search('><\/\|\(""\)\|^\s*$', a:flag ? 'Wpb' : 'Wp')
if pos == 3
startinsert!
elseif pos != 0
silent! normal! l
startinsert
endif
endfunction

View File

@@ -28,7 +28,8 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if val =~ '\s'
let sval = substitute(val, '\${cursor}', '', '')
if sval =~ '\s' || sval == ''
let str .= ' ' . attr . '="' . val . '"'
else
let str .= ' ' . attr . '=' . val
@@ -116,3 +117,13 @@ endfunction
function! zencoding#lang#slim#balanceTag(flag) range
endfunction
function! zencoding#lang#slim#moveNextPrev(flag)
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2
startinsert!
elseif pos != 0
silent! normal! l
startinsert
endif
endfunction