论坛上偷来的,感觉不错,哈哈。
set syntax=on
set cinoptions+={2,0,p0,t0
set nobackup
set cindent
set syntax=cpp
set formatoptions=tcqr
"注释掉某行
function Mycomm()
call append(line(".")-1,"/*")
call setline(line("."),getline("."))
call append(line("."), "date:".strftime("%c"))
call append(line(".")+1, "*/")
endf
"往文件开头增加一个文件说明
function Mytitle()
call append(0,"/**********************************************")
call append(1,"作者:猪头流氓")
call append(2,"时间:".strftime("%c"))
call append(3,"文件名:".expand("%"))
call append(4,"描述:")
call append(5,"**********************************************/")
endf
"往某行后面增加一个注释
function Mycomment()
if &syntax=="cpp" || &syntax=="c"
execute "normal \\a\/* */\2hi"
elseif &syntax=="perl" || &syntax=="sh"
execute "normal \\a\# \a"
endif
endf
map :call Mycomment()
map :call Mytitle():$o
map :call Mycomm()
map :1,$g/^$/dgg=G
阅读(641) | 评论(0) | 转发(0) |