【vim】gVim fun of the week(2)
令我头大的编码风格:
if(3 <= fun(x) || 6 >= fun(y)) {...}
if(fun(x)>=3 || fun(y)<=6) {...}
这样,头才不晕!
每次都这样机械地改,很浪费时间,倒不如写个函数,绑定到v_x上
vmap x c<C-R>=XOperand(@")<CR><ESC>
fun! XOperand(expr)
let xMap = {'<':'>', '<=':'>=', '>':'<', '>=':'<=', '==':'=='}
let mList = matchlist(a:expr,'^\s*\(.\{-}\)\s*\([<=>]=\?\)\s*\(.\{-}\)\s\{-}\n\?$')
if len(mList)
return mList[3].xMap[mList[2]].mList[1]
else
return a:expr
endif
endfun
#选中
3 <= fun(x)
#按下
x
#变成
fun(x)>=3
如果if(...)中只有一个比较运算符,则可以用vi(x,迅速搞定!
推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架