|
|
(未显示同一用户的9个中间版本) |
第1行: |
第1行: |
| 喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学! | | 喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学! |
|
| |
|
| if !has("signs")s1gns echoerr "Sorry, your vim does not support signs!"<br> finishs1gns endif
| | 最近写的一个gvim的marks脚本。方便自己方便大家! |
|
| |
|
| "[ 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>
| | 链接 http://www.vim.org/scripts/script.php?script_id=2194<br> |
|
| |
|
| 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>
| | [[Image:Vim marks.PNG|vim marks]] |
|
| |
|
| 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> | | <br> |
喜欢使用ubuntu和vim,但是都不是很了解,都在慢慢学!
最近写的一个gvim的marks脚本。方便自己方便大家!
链接 http://www.vim.org/scripts/script.php?script_id=2194