• 重写了index


    今天我把过index重新写了一下,没有做很大的改动,主要是对于一些小的bug修正了一下,同时对三个函数之间的关系分开了一下,可以模块化了,同时加入了很的注释,这个很重要,对于我以后写的代码,我都要加上一定的注释,不然时间一长我真的看不懂了,呵呵! 一个大的功能是可以对于不同的类型的文件用不同的正则,我常用的文件都加了进去了,本来还想是不是可以即时的动手修改,但是好像不可以,这应该是我对于vim的一个理解上的错。 还有就是不再分成几个部分了,按照文件里的顺序排的。 "2011.12.30去掉了有关于NERTree的部份.我一般还是用tex比较多,不用这部份的ide "目录的建立也不再分类,而是按照文章的顺序来,一来是方便不同方件类型二来也降低了 "函数的难度 " "修正了一个过去的bug map <silent> i :call Main_of_index()<CR> "{{{ ""主函数 function Main_of_index() "这个是从文件中提取的目录的正则与其输出格式,可以在不同文件中修改 if !exists("g:indexmode") let g:indexmode=['^.?{{{(.*)'] endif if !exists("g:indexcontract") let g:indexcontract=[' 1'] endif "g:Tag_is_run 的作用是检查index是不是工作状态 if !exists("g:Tag_is_run") let g:Tag_is_run=1 "窗口的缓冲号 let g:nu_buf_of_win={} let g:nu_buf_of_win.File=bufnr("%") "打开index窗口 leftabove 25vsplit Index set nonu setlocal buftype=nofile setlocal bufhidden=hide setlocal noswapfile let g:nu_buf_of_win.Tag=bufnr("%") map <silent><buffer> <CR> :call  Open_the_index()<CR> map <silent><buffer> o :call  Open_the_index()<CR> map <silent><buffer> u :call  Get_index()<CR> call    Get_index() return 0 endif "当index处于工作状态 "index的窗口是否打开 if bufwinnr(g:nu_buf_of_win.Tag) != -1 "退出index exe bufwinnr(g:nu_buf_of_win.Tag) . "wincmd w" q unlet g:Tag_is_run else "重新打开index unlet g:Tag_is_run call Main_of_index() endif return 0 endfunction "从文件中提取出目录,这个函数很重要是实际上的核心部分 "传递一个变量g:Numberlineinfile function Get_index() exe bufwinnr(g:nu_buf_of_win.File) . "wincmd w" let g:Numberlineinfile=[] let a:indexoffile=[] "生成相应的index列表 for n in range(1,line("$")) let Line_File=getline(n) for nn in range(1,len(g:indexmode)) let mx=g:indexmode[nn - 1] let format=g:indexcontract[nn - 1] if Line_File =~ mx call add(g:Numberlineinfile,n) call add(a:indexoffile,substitute(Line_File,mx,format,'')) endif endfor endfor exe bufwinnr(g:nu_buf_of_win.Tag) . "wincmd w" normal ggVGd call append("$",["  Index"]+ a:indexoffile) normal dd wincmd p endfunction ""打开光标下的目录 function Open_the_index() let line=g:Numberlineinfile[ line('.') -2 ] if line('.') > 1 exe bufwinnr(g:nu_buf_of_win.File) . "wincmd w" call cursor(line,1) endif endfunction< code>
  • 相关阅读:
    access生成sql脚本,通过VBA调用ADOX
    virtualbox 使用USB引导启动安装系统
    atom 调用g++编译cpp文件
    VPython 三维显示 —— hello word
    sql高级篇(一)
    sql基础篇
    struts2中的<s:select>默认选项
    关于SVN更新注意
    mysql中的substr()函数
    mysql中exists的用法介绍
  • 原文地址:https://www.cnblogs.com/fengidri/p/2757449.html
Copyright © 2020-2023  润新知