GVIM快速部署和笔记样例


0. summary

1. 下载GVIM
2. 安装Ctag
3. 安装Taglist
4. 安装TxtBrowser
5. 编辑_vimrc

1. 下载GVIM

主页:

https://www.vim.org/download.php

下载地址:

https://ftp.nluug.nl/pub/vim/pc/gvim81.exe

图形化安装略,这里安装到了F:\VIM

2. 安装Ctag

主页:

http://ctags.sourceforge.net/

下载地址:

http://prdownloads.sourceforge.net/ctags/ctags58.zip

解压的ctags58放在F:\Vim\vim81下

系统环境变量PATH中新建F:\Vim\vim81\ctags58

3. 安装Taglist

主页:

https://www.vim.org/scripts/script.php?script_id=273

使用作者提供的修改版本,以支持CJK: Chinese, Japanese, Korean

http://att.newsmth.net/att.php?p.731.55149.1226.vim

下载放到F:\Vim\vimfiles\plugin下

4. 安装TxtBrowser

主页:

https://www.vim.org/scripts/script.php?script_id=2899

下载地址:

https://www.vim.org/scripts/download_script.php?src_id=16207

解压的目录放在F:\Vim\vimfiles下

5. 编辑_vimrc

在用户目录下,比如C:\Users\impan\_vimrc

filetype plugin on 
au BufEnter *.txt setlocal ft=txt
set nu
colo desert
:nmap   :Tlist
:noremap   :TlistUpdate

if has('win32')      
    au GUIEnter * simalt ~x  
else      
    au GUIEnter * call MaximizeWindow()  
endif   
  
function! MaximizeWindow()      
    silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz  
endfunction

syntax on
let tlist_txt_settings = 'txt;c:content;f:figures;t:tables'
au BufRead,BufNewFile *.txt setlocal ft=txt

let Tlist_Auto_Open = 1
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1

"将键盘上的F4功能键映射为添加作者信息的快捷键  
map  ms:call TitleDet()'s  
function AddTitle()  
        call append(0,"#=============================================================================")
        call append(1,"#     FileName: ".expand("%:t")) 
        call append(2,"#         Desc: ") 
        call append(3,"#       Author: 胖熊猫")                            
        call append(4,"#        Email: [email protected]")
        call append(5,"#     HomePage: http://www.jianshu.com/u/322ac18b174f")  
        call append(6,"#      Version: 0.0.1")  
        call append(7,"#      Created: ".strftime("%Y-%m-%d %H:%M:%S"))  
        call append(8,"#   LastChange: ".strftime("%Y-%m-%d %H:%M:%S"))  
        call append(9,"#      History: ")         
        call append(10,"#=============================================================================")  
        echohl WarningMsg | echo "Successful in adding the copyright." | echohl None  
endf  
  
"更新最近修改时间和文件名  
function UpdateTitle()  
        normal m'  
        execute '/# *LastChange:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M:%S")@'  
        normal ''  
        normal mk  
        execute '/# *FileName:/s@:.*$@\=":\t".expand("%:t")@'  
        execute "noh"  
        normal 'k  
        echohl WarningMsg | echo "Successful in updating the copy right."| echohl None  
endfunction  
  
"判断前10行代码里面,是否有LastChange这个单词,  
"如果没有的话,代表没有添加过作者信息,需要新添加;  
"如果有的话,那么只需要更新即可  
function TitleDet()  
        let n=1  
        while n < 10  
                let line = getline(n)  
                if line =~'^\#\s*\S*LastChange:\S*.*$'  
                        call UpdateTitle()  
                        return  
                endif  
                let n = n + 1  
        endwhile  
        call AddTitle()  
endfunction

"将键盘上的F2功能键映射为===================================================================================================
map  ms:call AddTitle2()'s  
function AddTitle2()  
        call append(line(".")-1,"===================================================================================================")
        echohl WarningMsg | echo "Successful in adding the copyright." | echohl None  
endf

"将键盘上的F3功能键映射为*************************************************
map  ms:call AddTitle3()'s  
function AddTitle3()  
        call append(line(".")-1,"*************************************************")
        echohl WarningMsg | echo "Successful in adding the copyright." | echohl None  
endf  

noremap  :TlistToggle
noremap  :!ctags -R

6. 参考示例

打开要编辑的文件,上节参数中已经加入打开自动enable Txtbrowser,如果参数没有写,则每次要输入:Tlist(Vim末行模式)


F2加入章节横线区分结构


F4加入文件头


将左边的目录结构复制到正文中


保存关闭,一篇简单的笔记即做好


你可能感兴趣的:(GVIM快速部署和笔记样例)