查看“用户讨论:Corey”的源代码
来自Ubuntu中文
←
用户讨论:Corey
跳到导航
跳到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学! " copy this file to you plugin folder.<br>" put below one line <br>" let g:Signs_file_path_corey='c:\\'<br>" on your gvimrc, and you can change the path.<br>" --------------------------------------------------------------------- if !has("signs")<br> echoerr "Sorry, your vim does not support signs!"<br> finish<br>endif if has("win32")<br> let s:win32Flag = 1<br>else<br> let s:win32Flag = 0<br>endif "[ sign id, line number, file name]<br>let s:mylist = [["00","0","DO NOT CHANGE ANYTHING ABOUT THE FILE, THIS USE FOR VIM PLUGIN. BY HONGLI GAO @2008/03"]]<br>let s:myIndex = 1<br>let s:tmplist = [["00","0","corey"]]<br>let s:deleteFlag = 0<br>let s:outputFileName = "DO_NOT_DELETE_IT" " ---------------------------------------------------------------------<br>" put on one sign<br>fun! Place_sign() if !exists("s:Vm_sign_number")<br> let s:Vm_sign_number = 1<br> endif if s:Vm_sign_number > 99 <br> echo "Sorry, you only can use these marks less 100!"<br> return -1<br> endif let vLn = "".line(".")<br> let vFileName = expand("%:p") let vFlagNum = (s:Vm_sign_number < 10 ? "0" . s:Vm_sign_number : s:Vm_sign_number)<br> let newItem = [vFlagNum,vLn,vFileName]<br> let vIndex = s:Check_list(newItem) if vIndex > -1 <br> call s:Remove_sign(vIndex)<br> else <br> silent! exe 'sign define CS' . vFlagNum . ' text='. vFlagNum .' texthl=ErrorMsg'<br> silent! exe 'sign place ' . vFlagNum . ' line=' . vLn . ' name=CS'. vFlagNum . ' file=' . vFileName " record the last index.<br> let s:myIndex = s:Vm_sign_number<br> let s:Vm_sign_number = s:Vm_sign_number + 1<br> let s:mylist = s:mylist + [[vFlagNum,vLn,vFileName]]<br> endif <br> "echo s:mylist<br>endfun " ---------------------------------------------------------------------<br>" Remove all signs<br>fun! Remove_all_signs()<br> silent! exe 'sign unplace *'<br> if len(s:mylist) > 1 <br> let i = remove(s:mylist, 1, -1)<br> let s:Vm_sign_number = 1<br> endif<br> "echo s:mylist<br>endfun " ---------------------------------------------------------------------<br>" Goto prev sign:<br>fun! Goto_prev_sign()<br> if len(s:mylist) > 1<br> if s:deleteFlag == 0 <br> let s:myIndex = s:myIndex - 1<br> else<br> let s:deleteFlag = 0 <br> endif<br> <br> if s:myIndex <= 0<br> let s:myIndex = len(s:mylist) - 1<br> endif<br> call s:Sign_jump(s:mylist[s:myIndex][0], s:mylist[s:myIndex][2])<br> endif<br>endfun " ---------------------------------------------------------------------<br>" Goto next sign:<br>fun! Goto_next_sign()<br> if len(s:mylist) > 1<br> let s:myIndex = s:myIndex + 1<br> if ((s:myIndex >= len(s:mylist)) || (s:myIndex == 1))<br> let s:myIndex = 1<br> endif<br> call s:Sign_jump(s:mylist[s:myIndex][0], s:mylist[s:myIndex][2])<br> endif<br>endfun<br>" ---------------------------------------------------------------------<br>" Save_signs_to_file<br>fun! Save_signs_to_file() call s:Get_signs_file_name()<br> let tempList = []<br> for item in s:mylist<br> let tempList = tempList + [item[0] . "#" . item[1]. "#" . item[2]]<br> endfor<br> let writeFlag = writefile(tempList, s:outputFileName)<br> <br>endfun<br>" ---------------------------------------------------------------------<br>" Load_signs_from_file<br>fun! Load_signs_from_file() call s:Get_signs_file_name()<br> if filereadable(s:outputFileName)<br> let tempList = [[]]<br> let iflag = 0<br> for line in readfile(s:outputFileName)<br> let first = stridx(line, "#", 0)<br> let second = stridx(line, "#", first + 1)<br> if iflag != 0 <br> let tempList = tempList + [[strpart(line, 0, first), strpart(line, first + 1, second - first - 1), strpart(line, second + 1)]]<br> else<br> let tempList = [[strpart(line, 0, first), strpart(line, first + 1, second - first - 1), strpart(line, second + 1)]]<br> endif<br> let iflag = 1<br> endfor<br> let s:mylist = tempList<br> endif<br> <br> call s:Flash_signs() "echo s:mylist <br>endfun " ---------------------------------------------------------------------<br>fun! s:Get_signs_file_name()<br> if exists("g:Signs_file_path_corey")<br> let s:outputFileName = g:Signs_file_path_corey . "_DO_NOT_DELETE_IT"<br> endif<br>endfun " ---------------------------------------------------------------------<br>fun! s:Sign_jump(aSignID, aFileName)<br> silent! exe 'sign jump '. a:aSignID . ' file='. a:aFileName<br>endfun " ---------------------------------------------------------------------<br>" Remove one sign<br>fun! s:Remove_sign(aIndex) silent! exe 'sign unplace ' .s:mylist[a:aIndex][0] . ' file=' . s:mylist[a:aIndex][2]<br> <br> " record the before item<br> let s:tmplist = s:mylist[a:aIndex - 1]<br> <br> let i = remove(s:mylist_1, a:aIndex) " record the current index.<br> let s:myIndex = s:Check_list(s:tmplist) <br> let s:deleteFlag = 1<br> "echo s:mylist<br>endfun " ---------------------------------------------------------------------<br>fun! s:Flash_signs()<br> <br> silent! exe 'sign unplace *'<br> if len(s:mylist) > 1 <br> for item in s:mylist<br> silent! exe 'sign define CS' . item[0] . ' text='. item[0] .' texthl=ErrorMsg'<br> silent! exe 'sign place ' . item[0] . ' line=' . item[1] . ' name=CS'. item[0] . ' file=' . item[2]<br> endfor<br> endif<br>endfun " ---------------------------------------------------------------------<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)<br> let vResult = -1<br> let index = 0 if s:win32Flag == 1<br> for item in s:mylist<br> " file name is ignoring case<br> if ((item[1] ==? a:aItem[1]) && (item[2] ==? a:aItem[2]))<br> return index<br> endif<br> let index = index + 1<br> endfor<br> else<br> for item in s:mylist<br> " file name is matching case<br> if ((item[1] ==# a:aItem[1]) && (item[2] ==# a:aItem[2]))<br> return index<br> endif<br> let index = index + 1<br> endfor<br> endif return vResult<br>endfun " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*<br>" TODO<br>" I want to jump to the close file with this, but I can't now,<br>" so I copy these from s:Sign_jump to here. And below this function,<br>" all of them used for the jump.<br>fun! Test_open_jump()<br> "let bufferList = s:GetBufferList()<br> "echo bufferList<br> "let bufferExits = s:Seach_file(a:aFileName, bufferList)<br> "unlet bufferList<br> "if bufferExits >= 0 <br> " silent! exe 'sign jump_1 '. a:aSignID . ' file='. a:aFileName<br> "else<br> "call s:Open_file(a:aFileName)<br> "silent! exe 'sign jump '. a:aSignID . ' file='. a:aFileName<br> "endif endfun<br>" ---------------------------------------------------------------------<br>" get buffer list <br>fun! s:GetBufferList()<br> <br> let vResult = []<br> let bufcount = bufnr('$')<br> let buflist = '' " iterate through the buffers<br> let i = 0 | while i < bufcount | let i = i + 1<br> let bufname = bufname(i) " add the name to the list<br> let vResult = vResult + [bufname] endwhile<br> return vResult<br>endfun " ---------------------------------------------------------------------<br>" open file<br>fun! s:Open_file(aFileName_1)<br> if tabpagenr('$') > 1 <br> silent! exe 'tabnew '. a:aFileName<br> else<br> silent! exe 'e '. a:aFileName<br> endif<br>endfun<br>" ---------------------------------------------------------------------<br>" search file<br>" find the file, return the position; else return -1<br>fun! s:Seach_file(aFileName, aBufferList) let vResult = -1<br> let index = 0 if len(a:aBufferList) > 1 <br> if s:win32Flag == 1<br> for item in a:aBufferList<br> " file name is ignoring case<br> if (item ==? a:aFileName)<br> return index<br> endif<br> let index = index + 1<br> endfor<br> else<br> for item in a:aBufferList<br> " file name is matching case<br> if (item ==# a:aFileName_1)<br> return index<br> endif<br> let index = index + 1<br> endfor<br> endif <br> endif<br> return vResult<br>endfun<br>" ---------------------------------------------------------------------<br> if exists("g:Signs_file_path_corey") <br> let g:Signs_file_path_corey = g:Signs_file_path_corey . Pbname <br> call Load_signs_from_file()<br> endif<br>19,21,54,116,122,124<br><br>
返回
用户讨论:Corey
。
导航菜单
页面操作
用户页
讨论
阅读
查看源代码
历史
页面操作
用户页
讨论
更多
工具
个人工具
登录
导航
首页
最近更改
随机页面
页面分类
帮助
搜索
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
用户贡献
日志
查看用户组
特殊页面
页面信息