linux在vi中练习

linux在vi中练习,第1张

mkdri vitest cd vitest

cp /etc/man.config /tmp/vitest

vi man.config

按住Esc+Shift,在按冒号,然后输入set number

.......你要干嘛?

(1) 下面( )方式可以查看“cp ”命令的帮助。

#选D,每个命令都可以用--help来查看其帮助文档

(2) 在vi 中从“可视模式”切换到 “命令模式”使用( )。

#选B

(3) 下面(D )是“ssh ”命令正确的使用方法。

#D

(4) 关于“mkdir -p /fringe/oliva ”命令说法正确的是( )。

#C

(5) 使用( )可以使当前行出现上一行的最后一组参数。

#C

(6) 下列不属于Linux 桌面环境的是( )。

#B

(7) 下列关于Linux 桌面环境说法正确的是 ()。

#D在 linux系统桌面可以安装也可以不安装,并不是必须的,可以装一个也可以装两个,如gnome,kde

(8) 在vim 中使用( )可以保存并退出当前编辑的文件。

#D W是保存,Q是退出

(9) 使用( )可以清除屏幕所有内容。

# B

(10) 下列关于telnet 服务说法正确的是 ()。

#D telnet是明文传输

希望对你有用

回答这个问题很蛋疼啊

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

将下面2个函数放入vimrc或者在plugin文件夹新建一个.vim文件

调用:

:call Reply_Baidu()<cr>

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


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8689911.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-19
下一篇 2023-04-19

发表评论

登录后才能评论

评论列表(0条)

保存