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

@@ -1,7 +1,7 @@
"=============================================================================
" zencoding.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 30-May-2012.
" Last Change: 31-May-2012.
let s:save_cpo = &cpo
set cpo&vim
@@ -407,16 +407,14 @@ function! zencoding#expandAbbr(mode) range
endfunction
function! zencoding#moveNextPrev(flag)
if search('><\/\|\(""\)\|^\s*$', a:flag ? 'Wpb' : 'Wp') == 3
startinsert!
else
silent! normal! l
startinsert
endif
let type = zencoding#getFileType()
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.type.'.vim')) ? type : 'html'
return zencoding#lang#{rtype}#moveNextPrev(a:flag)
endfunction
function! zencoding#imageSize()
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.&ft.'.vim')) ? &ft : 'html'
let type = zencoding#getFileType()
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.type.'.vim')) ? type : 'html'
return zencoding#lang#{rtype}#imageSize()
endfunction
@@ -426,6 +424,12 @@ function! zencoding#toggleComment()
return zencoding#lang#{rtype}#toggleComment()
endfunction
function! zencoding#balanceTag(flag) range
let type = zencoding#getFileType()
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.type.'.vim')) ? type : 'html'
return zencoding#lang#{rtype}#balanceTag(a:flag)
endfunction
function! zencoding#splitJoinTag()
let curpos = getpos('.')
while 1
@@ -511,11 +515,6 @@ function! zencoding#removeTag()
endwhile
endfunction
function! zencoding#balanceTag(flag) range
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.&ft.'.vim')) ? &ft : 'html'
return zencoding#lang#{rtype}#balanceTag(a:flag)
endfunction
function! zencoding#anchorizeURL(flag)
let mx = 'https\=:\/\/[-!#$%&*+,./:;=?@0-9a-zA-Z_~]\+'
let pos1 = searchpos(mx, 'bcnW')

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