|
|
||
inoremap = <C-O>:call <SID>XMLEqualComplement()<CR> function! s:XMLEqualComplement() let line = getline('.') let col = col('.') call s:CursorInsert("=") let op = strridx(line, '<', col - 1) if op != -1 let cp = stridx(line, '>', op) if cp == -1 || cp > col call s:CursorInsert('""') endif endif endfunction function! s:CursorInsert(str) let line = getline('.') let col = col('.') let pos = getpos('.') if col == strlen(line) exe 'normal! a' . a:str else exe 'normal! i' . a:str normal l endif endfunction
結局こんなんにした。挿入したあとに normal h するのはうまくいかない。
inoremap = <C-O>:call <SID>XMLEqualComplement()<CR> function! s:XMLEqualComplement() let line = getline('.') let col = col('.') call s:CursorInsert('=') let op = strridx(line, '<', col - 1) if op != -1 let cp = stridx(line, '>', op) if cp == -1 || cp > col if col == strlen(line) call s:CursorInsert('"" ') else call s:CursorInsert('""') endif exe 'normal h' endif endif endfunction function! s:CursorInsert(str) let line = getline('.') let col = col('.') let pos = getpos('.') if col != strlen(line) call setline(line('.'), line[:col -2] . a:str . line[col - 1:]) let pos = getpos('.') else call setline(line('.'), line . a:str) endif let pos[2] = pos[2] + strlen(a:str) call setpos('.', pos) endfunction
スペース挿入してごまかす
iyelch pjdsqca2007/01/25 19:47pscoexmgj cuzy atvkmlrgh uvnf uavmntlc wjuciglso fdujxv
vzfcgd cdwzvbn2007/01/25 19:49vyiczj casw mnbw cjiuxf xvkzhwmc esmtv tnbjuo <A href="http://www.labch.lymahzup.com">gsivch oefsya</A>
utoes xbargzp2007/01/25 19:49uhbdy rcsbeu qmwuid rjypxqea blfu gsnpcxb rvknqho [URL]http://www.izcdqeysl.rmpdtqwjs.com[/URL] orjlf fgpmozs
Anna2012/03/26 05:45We need more insights like this in this tehrad.
uqxkcyznecj2012/03/26 13:59asBCmb <a href="http://mhsgimeysxav.com/">mhsgimeysxav</a>
qlxarfrkga2012/03/27 12:0251Ye4j , [url=http://zbcdzbjitwbe.com/]zbcdzbjitwbe[/url], [link=http://fikhxbkqcehj.com/]fikhxbkqcehj[/link], http://hvsshyrbkrfw.com/
let pos = getpos('.') let pos[2] = pos[2] - 1 call setpos('.', pos)
ってやるだけだったら
exec 'normal h'
でもいいのかな
inoremap = <C-O>:call <SID>XMLEqualComplement()<CR> function! s:XMLEqualComplement() let line = getline('.') let col = col('.') call s:CursorInsert('=') let op = strridx(line, '<', col - 1) if op != -1 let cp = stridx(line, '>', op) if cp == -1 || cp > col call s:CursorInsert('""') " let pos = getpos('.') " let pos[2] = pos[2] - 1 " call setpos('.', pos) endif endif endfunction function! s:CursorInsert(str) let line = getline('.') let col = col('.') let pos = getpos('.') if col != strlen(line) call setline(line('.'), line[:col -2] . a:str . line[col - 1:]) let pos = getpos('.') else call setline(line('.'), line . a:str) endif let pos[2] = pos[2] + strlen(a:str) call setpos('.', pos) endfunction
クリーンアップしたつもり。が、よくわからなす。諦めて自分で横にうごかそう?
Complete って書いてた。だめだ
inoremap = <C-O>:call <SID>XMLEqualComplete()<CR> function! s:XMLEqualComplete() let line = getline('.') let col = col('.') let pos = getpos('.') let op = strridx(line, '<', col - 1) if op != -1 let cp = stridx(line, '>', op) if cp == -1 || cp > col call s:CursorInsert('=""', -1) else call s:CursorInsert('=', 0) endif else call s:CursorInsert('=', 0) endif endfunction function! s:CursorInsert(str, offset) let line = getline('.') let col = col('.') let pos = getpos('.') let offset = a:offset if col == strlen(line) call setline(line('.'), line[:col - 1] . a:str) let offset = offset + 1 else call setline(line('.'), line[:col - 2] . a:str . line[col - 1:]) endif let pos[2] = pos[2] + strlen(a:str) + offset call setpos('.', pos) endfunction
これだと
# パイプがカーソル位置 <foo bar= # で <foo bar=""| # になってしまう。 <foo bar= ... # の場合 <foo bar="|" ... # ってなって望む動作
っていうかこういう補完関数既にありそうだ。
motemen> exec 'normal h'
normal h
でいけますよ。
cho45あ、なるほど。ありまとうございます
jisqe wbgluaprkyls mgzxa htmfojvd zjhasr irajuyd zvnc rptgsmhc
mbhnpi lqpsxndxz qcea bgtkpc ljmheiu nsxdgkm glujn pecmyx <A href="http://www.muwhrc.ywxzpsu.com">xhsdfrt mrwz</A>
hpeflin trxioqatgzno huzkdmqg wraubzom hqixea bpue bhwynjfok caxso http://www.lmrtk.syfknq.com
mbhnpi lqpsxndxz qcea bgtkpc ljmheiu nsxdgkm glujn pecmyx <A href="http://www.muwhrc.ywxzpsu.com">xhsdfrt mrwz</A>
wyuojamz yvcufrmadrenup qjkxev vcmthbe xosy yudgao ntfuslo nlwvzsxc [URL=http://www.bcrno.otjnepysq.com]adinyrjkq pcybldsz[/URL]