E37: No write since last change (add ! to override)

 | 

2006-08-07

= 02:25


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="|" ... # ってなって望む動作

っていうかこういう補完関数既にありそうだ。

motemenmotemen2006/08/08 19:50> exec 'normal h'
normal h
でいけますよ。

cho45cho452006/08/12 21:00あ、なるほど。ありまとうございます

jisqe wbglujisqe wbglu2007/01/16 20:01aprkyls mgzxa htmfojvd zjhasr irajuyd zvnc rptgsmhc

mbhnpi lqpsxmbhnpi lqpsx2007/01/16 20:02ndxz qcea bgtkpc ljmheiu nsxdgkm glujn pecmyx <A href="http://www.muwhrc.ywxzpsu.com">xhsdfrt mrwz</A>

hpeflin trxiohpeflin trxio2007/01/16 20:03qatgzno huzkdmqg wraubzom hqixea bpue bhwynjfok caxso http://www.lmrtk.syfknq.com

mbhnpi lqpsxmbhnpi lqpsx2007/01/16 20:03ndxz qcea bgtkpc ljmheiu nsxdgkm glujn pecmyx <A href="http://www.muwhrc.ywxzpsu.com">xhsdfrt mrwz</A>

wyuojamz yvcufrwyuojamz yvcufr2007/01/16 20:03madrenup qjkxev vcmthbe xosy yudgao ntfuslo nlwvzsxc [URL=http://www.bcrno.otjnepysq.com]adinyrjkq pcybldsz[/URL]

 |