zoukankan      html  css  js  c++  java
  • 如来神掌第二式第八招----VIM定制

    ###############################################################################
    # Name : Mahavairocana                                                                                                                                           
    # Author : Mahavairocana                                                                                                                                         
    # QQ : 10353512                                                                                                                                                    
    # WeChat : shenlan-qianlan                                                                                                                                      
    # Blog : http://www.cnblogs.com/Mahavairocana/                                                                                                       
    # Description : You are welcome to reprint, or hyperlinks to indicate the                                                                        
    #                    source of the article, as well as author information.                                                                                ###############################################################################

    把如下文件直接贴到root目录下,在编辑新文件的时候显示自定义信息。

    复制代码
    root@shenlan-qianlan:/home/python/day1# vim shenlanqianlan.sh
    #!/bin/bash
    #########################################################################
    # File Name: shenlanqianlan.sh
    # Author : Mahavairocana  
    # QQ : 10353512
    # Email:10353512@qq.com
    # Blog:http://www.cnblogs.com/shenlanqianlan/
    # Created Time: Wednesday, October 19, 2016 PM05:02:49 HKT
    #########################################################################
    复制代码

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    复制代码
    root@shenlan-qianlan:~# cat .vimrc 
    let g:pydiction_location = '~/.vim/after/complete-dict'
    let g:pydiction_menu_height = 20
    let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
    let g:miniBufExplMapWindowNavVim = 1
    let g:miniBufExplMapWindowNavArrows = 1
    let g:miniBufExplMapCTabSwitchBufs = 1
    let g:miniBufExplModSelTarget = 1
    
    autocmd FileType python set omnifunc=pythoncomplete#Complete
     
    set rtp+=~/.vim/bundle/vundle
    set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
    set termencoding=utf-8
    set encoding=utf-8
    set fileencodings=ucs-bom,utf-8,cp936
    set fileencoding=utf-8
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    """""新文件标题""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "新建.c,.h,.sh,.java文件,自动插入文件头 
    autocmd BufNewFile *.cpp,*.[ch],*.sh,*.py,*.java exec ":call SetTitle()" 
    ""定义函数SetTitle,自动插入文件头 
    func SetTitle() 
        "如果文件类型为.sh文件 
        if &filetype == 'sh' 
            call setline(1,"#!/bin/bash") 
            call append(line("."),"#########################################################################") 
            call append(line(".")+1, "# File Name: ".expand("%"))
            call append(line(".")+2, "# Author : Mahavairocana")
            call append(line(".")+3, "# QQ : 10353512")
            call append(line(".")+4, "# Email:10353512@qq.com")
            call append(line(".")+5, "# Blog:http://www.cnblogs.com/shenlanqianlan/")
            call append(line(".")+6, "# Created Time: ".strftime("%c"))
            call append(line(".")+7, "#########################################################################")
            call append(line(".")+8, "")
    
        elseif &filetype == 'python'
            call setline(1,"#!/usr/bin/env python")
            call append(line("."),"#########################################################################")
            call append(line(".")+1, "# File Name: ".expand("%"))
            call append(line(".")+2, "# Author :刘琪")
            call append(line(".")+3, "# QQ : 10353512")
            call append(line(".")+4, "# Email:10353512@qq.com")
            call append(line(".")+5, "# Blog:http://www.cnblogs.com/shenlanqianlan/")
            call append(line(".")+6, "# Created Time: ".strftime("%c"))
            call append(line(".")+7, "#########################################################################")
            call append(line(".")+8, "")
    
        else
            call setline(1, "/*************************************************************************") 
            call append(line("."), "    > File Name: ".expand("%")) 
            call append(line(".")+1, "# File Name: ".expand("%"))
            call append(line(".")+2, "# Author : Mahavairocana  ")
            call append(line(".")+3, "# QQ : 10353512")
            call append(line(".")+4, "# Email:10353512@qq.com")
            call append(line(".")+5, "# Blog:http://www.cnblogs.com/shenlanqianlan/")
            call append(line(".")+6, "# Created Time: ".strftime("%c"))
            call append(line(".")+7, " ************************************************************************/") 
            call append(line(".")+8, "")
    
        endif
        if &filetype == 'cpp'
            call append(line(".")+6, "#include<iostream>")
            call append(line(".")+7, "using namespace std;")
            call append(line(".")+8, "")
        endif
        if &filetype == 'c'
            call append(line(".")+6, "#include<stdio.h>")
            call append(line(".")+7, "")
        endif
        "新建文件后,自动定位到文件末尾
    endfunc 
    autocmd BufNewFile * normal G
    复制代码
  • 相关阅读:
    ElasticSearch基本学习
    Liunx下的系统负荷
    记录调试树(方便跟到具体的调用)
    树形结构的数据库的存储
    VS快速生成JSON数据格式对应的实体
    关于理想化的编程
    通过Chrome浏览器检测和优化页面
    一个关于Random算法的问题
    MVC中的一般权限管理
    文件读写锁
  • 原文地址:https://www.cnblogs.com/Mahavairocana/p/8290267.html
Copyright © 2011-2022 走看看