查看“用户讨论:Corey”的源代码
来自Ubuntu中文
←
用户讨论:Corey
跳到导航
跳到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学! if !has("signs")s1gns echoerr "Sorry, your vim does not support signs!"<br> finishs1gns endif "[ sign id, line number, file name]s1gns let s:mylist = [["00","0","DO NOT CHANGE ANYTHING ABOUT THE FILE"]]<br>let s:myIndex = 1s1gns let s:tmplist = [["00","0","corey"]]<br>let s:deleteFlag = 0s1gns <br>" ---------------------------------------------------------------------<br>" maping the keyboard <br>if !hasmapto('<Plug>Place_sign')s1gns map <unique> <c-F2> <Plug>Place_sign<br> map <silent> <unique> mm <Plug>Place_sign <br>endif<br>nnoremap <silent> <script> <Plug>Place_sign :call Place_sign()<cr> if !hasmapto('<Plug>Goto_next_sign')s1gns map <unique> <F2> <Plug>Goto_next_sign<br> map <silent> <unique> m. <Plug>Goto_next_sign <br>endif<br>nnoremap <silent> <script> <Plug>Goto_next_sign :call Goto_next_sign()<cr> if !hasmapto('<Plug>Goto_prev_sign')s1gns map <unique> <s-F2> <Plug>Goto_prev_sign<br> map <silent> <unique> mv <Plug>Goto_prev_sign <br>endif<br>nnoremap <silent> <script> <Plug>Goto_prev_sign :call Goto_prev_sign()<cr> if !hasmapto('<Plug>Remove_all_signs')s1gns map <unique> <F4> <Plug>Remove_all_signs<br>endif<br>nnoremap <silent> <script> <Plug>Remove_all_signs :call Remove_all_signs()<cr> " ---------------------------------------------------------------------<br>" put on one sign<br>fun! Place_sign()s1gns <br> if !exists("s:Sign_num")s1gns let s:Sign_num = 1<br> endifs1gns <br> if s:Sign_num > 99 s1gns echo "Sorry, you only can use these marks less 100!"<br> return -1s1gns endif<br>s1gns let vLn = "".line(".")<br> let vFileName = expand("%:p")s1gns <br> let vFlagNum = (s:Sign_num < 10 ? "0" . s:Sign_num : s:Sign_num)s1gns let newItem = [vFlagNum,vLn,vFileName]<br> "echo newItem s1gns let vIndex = s:Check_list(newItem)<br> "echo vIndexs1gns if vIndex > -1 <br> call s:Remove_sign(vIndex)s1gns else <br> "exec 'sign define CS' . vFlagNum . ' text='. vFlagNum .' linehl=NONE texthl=ErrorMsg's1gns exec 'sign define CS' . vFlagNum . ' text='. vFlagNum .' texthl=ErrorMsg'<br>s1gns "exe 'sign place ' . b:Sign_num . ' line=' . ln . ' name=CS'. FlagNum . ' buffer=' . winbufnr(0)<br> exe 'sign place ' . vFlagNum . ' line=' . vLn . ' name=CS'. vFlagNum . ' file=' . vFileNames1gns <br> " record the last index.s1gns let s:myIndex = s:Sign_num<br> let s:Sign_num = s:Sign_num + 1s1gns let s:mylist = s:mylist + [[vFlagNum,vLn,vFileName]]<br> endif s1gns "echo s:mylist<br> "unlet newItem<br>endfun " ---------------------------------------------------------------------<br>" Remove one sign<br>fun! s:Remove_sign(aIndex)s1gns <br> silent! exe 'sign unplace ' .s:mylist[a:aIndex][0] . ' file=' . s:mylist[a:aIndex][2]s1gns "echo 'sign unplace ' .s:mylist[a:aIndex][0] . ' file=' . s:mylist[a:aIndex][2]<br> s1gns " record the before item<br> let s:tmplist = s:mylist[a:aIndex - 1]s1gns <br> let i = remove(s:mylist, a:aIndex)s1gns <br> " record the current index.s1gns let s:myIndex = s:Check_list(s:tmplist) <br> let s:deleteFlag = 1s1gns "echo s:mylist<br>endfun " ---------------------------------------------------------------------<br>" Remove all signs<br>fun! Remove_all_signs()s1gns silent! exe 'sign unplace *'<br> if len(s:mylist) > 1 s1gns let i = remove(s:mylist, 1, -1)<br> let s:Sign_num = 1s1gns endif<br> "echo s:mylist<br>endfun <br>" ---------------------------------------------------------------------<br>" if line number and file name both same, return the aitem's index of s:mylist<br>" else return -1<br>" index 0 of s:mylist is the output message in the record file.<br>fun! s:Check_list(aItem)s1gns let vResult = -1<br> let index = 0s1gns <br> for item in s:mylists1gns "echo item[1] . "-" . a:aItem[1] . "=" . item[2] . "-" . a:aItem[2]<br> if ((item[1] ==? a:aItem[1]) && (item[2] ==? a:aItem[2]))s1gns return index<br> endifs1gns let index = index + 1<br> endfors1gns <br> return vResult<br>endfun " ---------------------------------------------------------------------<br>" Goto prev sign:<br>fun! Goto_prev_sign()s1gns if len(s:mylist) > 1<br> if s:deleteFlag == 0 s1gns let s:myIndex = s:myIndex - 1<br> elses1gns let s:deleteFlag = 0 <br> endifs1gns <br> if s:myIndex <= 0s1gns let s:myIndex = len(s:mylist) - 1<br> endifs1gns silent! exe 'sign jump '. s:mylist[s:myIndex][0] . ' file='. s:mylist[s:myIndex][2]<br> "echo 'sign jump '. s:mylist[s:myIndex][0] . ' file='. s:mylist[s:myIndex][2]s1gns endif<br>endfun " ---------------------------------------------------------------------<br>" Goto next sign:<br>fun! Goto_next_sign()s1gns if len(s:mylist) > 1<br> let s:myIndex = s:myIndex + 1s1gns if ((s:myIndex >= len(s:mylist)) || (s:myIndex == 1))<br> let s:myIndex = 1s1gns endif<br> silent! exe 'sign jump '. s:mylist[s:myIndex][0] . ' file='. s:mylist[s:myIndex][2]s1gns "echo 'sign jump '. s:mylist[s:myIndex][0] . ' file='. s:mylist[s:myIndex][2]<br> endif<br>endfun " ---------------------------------------------------------------------<br><br> <br> <br>
返回
用户讨论:Corey
。
导航菜单
页面操作
用户页
讨论
阅读
查看源代码
历史
页面操作
用户页
讨论
更多
工具
个人工具
登录
导航
首页
最近更改
随机页面
页面分类
帮助
搜索
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
用户贡献
日志
查看用户组
特殊页面
页面信息