永发信息网

最近在学LINUX遇到到一个难题,是关于VI编辑器的,回答的精彩必有加分!

答案:1  悬赏:40  手机版
解决时间 2021-03-28 05:12
最近在学LINUX遇到到一个难题,是关于VI编辑器的,回答的精彩必有加分!
最佳答案
回答这个问题很蛋疼啊

有一部分参考了插件calendar.vm

将下面2个函数放入vimrc或者在plugin文件夹新建一个.vim文件
调用:
:call Reply_Baidu()

function MY_Calendar(vyear,vmnth)
" get arguments
let vyear = a:vyear
let vmnth = a:vmnth
" start with last 6 month
let vmnth = vmnth - 6
if vmnth < 1
let vmnth = 12 - vmnth
let vyear = vyear - 1
endif
" reset display variables
let vmcnt = 0
while vmcnt < 12
let vcolumn = 22
let vnweek = -1
"--------------------------------------------------------------
"--- calculating
"--------------------------------------------------------------
" set boundary of the month
if vmnth == 1
let vmdays = 31
let vparam = 1
let vsmnth = 'Jan'
elseif vmnth == 2
let vmdays = 28
let vparam = 32
let vsmnth = 'Feb'
elseif vmnth == 3
let vmdays = 31
let vparam = 60
let vsmnth = 'Mar'
elseif vmnth == 4
let vmdays = 30
let vparam = 91
let vsmnth = 'Apr'
elseif vmnth == 5
let vmdays = 31
let vparam = 121
let vsmnth = 'May'
elseif vmnth == 6
let vmdays = 30
let vparam = 152
let vsmnth = 'Jun'
elseif vmnth == 7
let vmdays = 31
let vparam = 182
let vsmnth = 'Jul'
elseif vmnth == 8
let vmdays = 31
let vparam = 213
let vsmnth = 'Aug'
elseif vmnth == 9
let vmdays = 30
let vparam = 244
let vsmnth = 'Sep'
elseif vmnth == 10
let vmdays = 31
let vparam = 274
let vsmnth = 'Oct'
elseif vmnth == 11
let vmdays = 30
let vparam = 305
let vsmnth = 'Nov'
elseif vmnth == 12
let vmdays = 31
let vparam = 335
let vsmnth = 'Dec'
else
echo 'Invalid Year or Month'
return
endif
if vyear % 400 == 0
if vmnth == 2
let vmdays = 29
elseif vmnth >= 3
let vparam = vparam + 1
endif
elseif vyear % 100 == 0
if vmnth == 2
let vmdays = 28
endif
elseif vyear % 4 == 0
if vmnth == 2
let vmdays = 29
elseif vmnth >= 3
let vparam = vparam + 1
endif
endif

" calc vnweek of the day
if vnweek == -1
let vnweek = ( vyear * 365 ) + vparam
let vnweek = vnweek + ( vyear/4 ) - ( vyear/100 ) + ( vyear/400 )
if vyear % 4 == 0
if vyear % 100 != 0 || vyear % 400 == 0
let vnweek = vnweek - 1
endif
endif
let vnweek = vnweek - 1
endif

" fix Gregorian
if vyear <= 1752
let vnweek = vnweek - 3
endif

let vnweek = vnweek % 7

"--------------------------------------------------------------
"--- displaying
"--------------------------------------------------------------
" build header
let vdisplay2=vyear.'/'.vmnth.'('
let vdisplay2=strpart(" ",
\ 1,(vcolumn-strlen(vdisplay2))/2-2).vdisplay2
let vdisplay2=vdisplay2.vsmnth.')'."\n"
let vwruler = "Su Mo Tu We Th Fr Sa"
let vdisplay2 = vdisplay2.' '.vwruler."\n"

" build calendar
let vinpcur = 0
while (vinpcur < vnweek)
let vdisplay2=vdisplay2.' '
let vinpcur = vinpcur + 1
endwhile

let vdaycur = 1
let vdisplay2 = vdisplay2.' '
while (vdaycur <= vmdays)
if vmnth < 10
let vtarget =vyear."0".vmnth
else
let vtarget =vyear.vmnth
endif
if vdaycur < 10
let vtarget = vtarget."0".vdaycur
else
let vtarget = vtarget.vdaycur
endif
let vsign = ''

if vdaycur < 10
let vdisplay2=vdisplay2.' '
endif
let vdisplay2=vdisplay2.vdaycur
let vdaycur = vdaycur + 1

" fix Gregorian
if vyear == 1752 && vmnth == 9 && vdaycur == 3
let vdaycur = 14
endif

let vinpcur = vinpcur + 1
if vinpcur % 7 == 0
let vdisplay2=vdisplay2."\n"
endif
let vdisplay2 = vdisplay2.' '
endwhile
let vmnth = vmnth + 1
let vmcnt = vmcnt + 1
if vmnth > 12
let vmnth = 1
let vyear = vyear + 1
endif
silent put =vdisplay2
endwhile

return
endfunction

function Reply_Baidu()

exe "normal ggdG"
" 插入日历
call MY_Calendar(2009,7)
exe "w 2009.txt"

" 标题变为2009全年日历
call append(1,"\t2009 Calendar")

" 每个月的行数
let jan = search("Jan")
let feb = search("Feb")
let mar = search("Mar")
let apr = search("Apr")
let may = search("May")
let jun = search("Jun")
let jul = search("Jul")
let aug = search("Aug")
let sep = search("Sep")
let oct = search("Oct")
let nov = search("Nov")
let dec = search("Dec")

" 移动4-6月
let line = apr
while line < jul
call cursor(line,1)
exe ">"
let line = line + 1
endwhile

" 删除123 再恢复 这不蛋疼么
let line = apr-jan
call cursor(jan,1)
exe "normal d".line."d"
exe "normal kp"

" 7 8 9 移动到最后
let line = oct - jul
call cursor(jul,1)
exe "normal d".line."d"
exe "normal Gp"

" 检测30 并删除
let line = 1
echo line('$')
while line <= line('$')
if getline(line) =~ '\<30\>'
if getline(line) =~ '\<31\>' || getline(line+1) =~ '\<31\>'
let line = line + 1
continue
else
call cursor(line,1)
exe "normal f3d$"
endif
endif
let line = line + 1
endwhile

" 最后保存
exe "w 2009.txt"

endfunction
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
i want you i n my room 什么意思
庐山恋2010中 1小时17分左右 秦岚母女抽牌时
从山海关到丽江自驾游 一路上都哪有好玩的路
从此以后你不在是我的某某歌名是什么?
为什么花蛤泡水里都死了?
有关部门最近发出通知,要求各地在中考期间严
想买一万块钱的二手车,除了裸车费用外还需要
东港新村西北门怎么去啊,有知道地址的么
海南原住民是什么民族
支付宝账户的支付密码指的是什么密码
填一填.1.蚕吐丝--( )2.辞旧碎--
一个七十多岁的人,先打我,我又还手打了她怎
计算下列物质的相对分子质量CO2的相对分子质
上海土质是几类土?
黑龙江海林有哪些知名景点?
推荐资讯
西部数据WD20PURX和希捷ST2000DM001哪个好
王嘉尔Jackson的昵称
泗这个字念什么字
这是什么鼠类?我们这里叫毛老鼠?
春天的农谚句子有哪些,请各位大神解答
沈阳z3050-16/1摇臂钻床大臂锁不住怎么回
42.6×10.1-4.26怎么简便?
45号钢硬度在多少左右才容易加工。
钢笔和中型笔,有什么优点和缺点?
明朗少女成功记百度云免费资源共享
唐朝韦庄写的《燕来》这首诗是什么意思?
现在还有所谓的家族联姻嘛?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?