用户讨论:Corey:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Corey留言 | 贡献
无编辑摘要
Corey留言 | 贡献
正在将页面替换为 '喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学! 最近写的一个gvim的marks脚本。方便自己方便大家! 链接 http://www.vim.org/scr...'
第7行: 第7行:
[[Image:Vim marks.PNG|vim marks]]
[[Image:Vim marks.PNG|vim marks]]


let s:remarkItem = ["REMARK","SEARCH","FLAG"]<br>
<br>
 
" remark<br>fun! Move_sign()
 
let s:tempItem = ["","",""]<br> let vRLn = "".line(".")<br> let vRFileName = expand("%:p")
 
let s:tempItem[1] = vRLn<br> let s:tempItem[2] = vRFileName<br> "echo s:tempItem <br> let vRIndex = s:Check_list(s:tempItem)
 
if (s:remarkItem[0] ==# "REMARK" ) <br> if vRIndex &gt; 0<br> silent! exe 'sign define CS' . s:mylist[vRIndex][0] . ' text='. s:mylist[vRIndex][0] .' texthl=Search'<br> silent! exe 'sign place ' . s:mylist[vRIndex][0] . ' line=' . vRLn . ' name=CS'. s:mylist[vRIndex][0] . ' file=' . vRFileName<br> let s:remarkItem = s:mylist[vRIndex]<br> let s:myIndex = vRIndex<br> "echo s:remarkItem<br> endif<br> else<br> let pionter = s:Check_list(s:remarkItem)<br> "echo vRIndex ."|" .pionter <br> if ((vRIndex &lt; 0) &amp;&amp; (pionter &gt; 0)) <br> silent! exe 'sign unplace ' .s:remarkItem[0] . ' file=' . s:remarkItem[2]<br> "silent! exe 'sign undefine' .s:remarkItem[0]<br> "echo 'sign define CS' . s:remarkItem[0] . ' text='. s:remarkItem[0] .' texthl=ErrorMsg'<br> silent! exe 'sign define CS' . s:remarkItem[0] . ' text='. s:remarkItem[0] .' texthl=ErrorMsg'<br> "echo 'sign place ' . s:remarkItem[0] . ' line=' . s:remarkItem[1] . ' name=CS' . s:remarkItem[0] . ' file=' . s:remarkItem[2]<br> silent! exe 'sign place ' . s:remarkItem[0] . ' line=' . vRLn . ' name=CS' . s:remarkItem[0] . ' file=' . vRFileName<br> let s:mylist[pionter][1] = vRLn<br> let s:mylist[pionter][2] = vRFileName<br> "echo s:mylist[pionter]<br> let s:myIndex = pionter<br> let s:remarkItem = ["REMARK","SEARCH","FLAG"]<br> endif<br> endif<br>endfun<br> " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*<br>" all of them used for the jump.<br>fun! s:Sign_jump(aSignID, aFileName)<br> let bufferList = s:GetBufferList()<br> "echo bufferList<br> let bufferExits = s:Seach_file(a:aFileName, bufferList)
 
if bufferExits &gt; 0<br> silent! exe 'tabn ' . bufferExits<br> silent! exe 'sign jump '. a:aSignID[0] . ' file='. a:aFileName<br> else<br> call s:Open_file(a:aFileName)
 
silent! exe 'sign place ' . a:aSignID[0] . ' line=' . a:aSignID[1] . ' name=CS'. a:aSignID[0] . ' file=' . a:aSignID[2]
 
silent! exe 'sign jump '. a:aSignID[0] . ' file='. a:aFileName<br> endif
 
endfun<br>" ---------------------------------------------------------------------<br>" get buffer list <br>fun! s:GetBufferList()<br> <br> let vResult = [["0","[ * THE &lt;?&gt; HEAD * ]"]]<br> let i = 0
 
while i &lt; tabpagenr('$')
 
"exe 'tabn ' . i + 1<br> if i == 0 <br> silent! exe 'tabfirst'<br> else<br> silent! exe 'tabnext'<br> endif<br> let bufname = expand("%:p")<br> let vResult = vResult + [[i + 1, bufname]]<br> let i = i + 1<br> endwhile <br> <br> return vResult<br>endfun
 
" ---------------------------------------------------------------------<br>" open file<br>fun! s:Open_file(aFileName)<br> if filereadable(a:aFileName)<br> "call s:Flash_signs()<br> if tabpagenr('$') &gt; 1 <br> silent! exe 'tabnew '. a:aFileName<br> silent! exe 'tabn ' . tabpagenr('$')<br> else<br> silent! exe 'e '. a:aFileName<br> endif<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
 
if len(a:aBufferList) &gt; 1 <br> if s:win32Flag == 1<br> for item in a:aBufferList<br> " file name is ignoring case<br> if (item[1] ==? a:aFileName)<br> return item[0]<br> endif<br> endfor<br> else<br> for item in a:aBufferList<br> " file name is matching case<br> if (item[1] ==# a:aFileName)<br> return item[0]<br> endif<br> endfor<br> endif <br> endif<br> return vResult<br>endfun<br>" ---------------------------------------------------------------------<br><br>

2008年4月12日 (六) 20:49的版本

喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学!

最近写的一个gvim的marks脚本。方便自己方便大家!

链接 http://www.vim.org/scripts/script.php?script_id=2194

vim marks