码迷,mamicode.com
首页 > 系统相关 > 详细

我的VIM。。。

时间:2015-04-10 14:58:21      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
  let opt = ‘-a --binary ‘
  if &diffopt =~ ‘icase‘ | let opt = opt . ‘-i ‘ | endif
  if &diffopt =~ ‘iwhite‘ | let opt = opt . ‘-b ‘ | endif
  let arg1 = v:fname_in
  if arg1 =~ ‘ ‘ | let arg1 = ‘"‘ . arg1 . ‘"‘ | endif
  let arg2 = v:fname_new
  if arg2 =~ ‘ ‘ | let arg2 = ‘"‘ . arg2 . ‘"‘ | endif
  let arg3 = v:fname_out
  if arg3 =~ ‘ ‘ | let arg3 = ‘"‘ . arg3 . ‘"‘ | endif
  let eq = ‘‘
  if $VIMRUNTIME =~ ‘ ‘
    if &sh =~ ‘\<cmd‘
      let cmd = ‘""‘ . $VIMRUNTIME . ‘\diff"‘
      let eq = ‘"‘
    else
      let cmd =
      substitute($VIMRUNTIME, ‘ ‘, ‘" ‘, ‘‘) . ‘\diff"‘
    endif
  else
    let cmd = $VIMRUNTIME . ‘\diff‘
  endif
  silent execute ‘!‘ . cmd . ‘ ‘ . opt . arg1 . ‘ ‘ . arg2 . ‘ > ‘ . arg3 . eq
endfunction

syntax on                               "高亮
"colo torte                              "配色
set guifont=Microsoft_YaHei_Mono:h11    "字体
set lines=26 columns=93                 "gvim窗口大小
set nu                                    "行号开关
set history=100000                      "最大历史
set autoindent                          "自动缩进
set tabstop=4                           "一个TAB长度
set softtabstop=4                         "退格键的时候退回缩进的长度
set shiftwidth=4                         "每一级缩进的长度
set smarttab                              "自动缩进
set cindent                              "C风格自动缩进
set nobackup                             "不生成备份文件
set noswapfile                          "不生成swap文件
set mouse=a                             "光标定位到鼠标位置


"C,C++,Java 按F5编译运行
map <F5> :call CompileRun()<CR>
func! CompileRun()
    exec "w"
    if &filetype == ‘c‘
        exec "!g++ -o run %"
"        exec "!run"
    elseif &filetype == ‘cpp‘
        exec "!g++ -o run %"
"        exec "!run"
    elseif &filetype == ‘java‘ 
        exec "!javac -d .\\bin %" 
        exec "!java -cp .\\bin %<"
    elseif &filetype == ‘sh‘
        :!./%
    endif
endfunc

imap <c-]> {<cr>}<c-o>O<left><right> 
map <F2> :call SetTitle1()<CR> 
func SetTitle1() 
let l = 0 
let l = l + 1 | call setline(l,‘#include <bits/stdc++.h>‘) 
let l = l + 1 | call setline(l,‘#define PF(x) ((x)*(x))‘) 
let l = l + 1 | call setline(l,‘#define LF(x) ((x)*PF(x))‘) 
let l = l + 1 | call setline(l,‘#define IF(i,x,y) for(int i=x;i<=y;i++)‘) 
let l = l + 1 | call setline(l,‘#define DF(i,x,y) for(int i=x;i>=y;i--)‘) 
let l = l + 1 | call setline(l,‘#define normal‘)
let l = l + 1 | call setline(l,‘#ifndef normal‘) 
let l = l + 1 | call setline(l,‘    #define LL __int64‘) 
let l = l + 1 | call setline(l,‘#endif // normal‘) 
let l = l + 1 | call setline(l,‘#ifdef normal‘) 
let l = l + 1 | call setline(l,‘    #define LL long long‘) 
let l = l + 1 | call setline(l,‘#endif // normal‘)
let l = l + 1 | call setline(l,‘‘) 
let l = l + 1 | call setline(l,‘using namespace std;‘) 
let l = l + 1 | call setline(l,‘const int INF=1<<31-1;‘) 
let l = l + 1 | call setline(l,‘const int inf=0x3f3f3f3f;‘) 
let l = l + 1 | call setline(l,‘const double pi=4.0*atan(1.0);‘) 
let l = l + 1 | call setline(l,‘const int mod=1000000007;‘) 
let l = l + 1 | call setline(l,‘const double EXP=1e-8;‘) 
let l = l + 1 | call setline(l,‘const double E=exp(1.0);‘) 
let l = l + 1 | call setline(l,‘‘) 
let l = l + 1 | call setline(l,‘int main()‘) 
let l = l + 1 | call setline(l,‘{‘) 
let l = l + 1 | call setline(l,‘    //freopen("in.txt","r",stdin);‘) 
let l = l + 1 | call setline(l,‘    //freopen("out.txt","w",stdout);‘) 
let l = l + 1 | call setline(l,‘    ‘) 
let l = l + 1 | call setline(l,‘    return 0;‘) 
let l = l + 1 | call setline(l,‘}‘) 
endfunc  
map <F3> :call SetTitle()<CR> 
func SetTitle() 
let l = 0 
let l = l + 1 | call setline(l,‘#include<iostream>‘) 
let l = l + 1 | call setline(l,‘#include<algorithm>‘) 
let l = l + 1 | call setline(l,‘#include<cstdio>‘) 
let l = l + 1 | call setline(l,‘#include<cctype>‘) 
let l = l + 1 | call setline(l,‘#include<cstring>‘) 
let l = l + 1 | call setline(l,‘#include<string>‘) 
let l = l + 1 | call setline(l,‘#include<map>‘) 
let l = l + 1 | call setline(l,‘#include<set>‘) 
let l = l + 1 | call setline(l,‘#include<stack>‘) 
let l = l + 1 | call setline(l,‘#include<queue>‘) 
let l = l + 1 | call setline(l,‘#include<cstdilib>‘) 
let l = l + 1 | call setline(l,‘#include<vector>‘) 
let l = l + 1 | call setline(l,‘#include<cmath>‘) 
let l = l + 1 | call setline(l,‘#include<iomanip>‘) 
let l = l + 1 | call setline(l,‘#define PF(x) ((x)*(x))‘) 
let l = l + 1 | call setline(l,‘#define LF(x) ((x)*PF(x))‘) 
let l = l + 1 | call setline(l,‘#define IF(i,x,y) for(int i=x;i<=y;i++)‘) 
let l = l + 1 | call setline(l,‘#define DF(i,x,y) for(int i=x;i>=y;i--)‘) 
let l = l + 1 | call setline(l,‘#define normal‘)
let l = l + 1 | call setline(l,‘#ifndef normal‘) 
let l = l + 1 | call setline(l,‘    #define LL __int64‘) 
let l = l + 1 | call setline(l,‘#endif // normal‘) 
let l = l + 1 | call setline(l,‘#ifdef normal‘) 
let l = l + 1 | call setline(l,‘    #define LL long long‘) 
let l = l + 1 | call setline(l,‘#endif // normal‘) 
let l = l + 1 | call setline(l,‘‘) 
let l = l + 1 | call setline(l,‘using namespace std;‘) 
let l = l + 1 | call setline(l,‘const int INF=1<<31-1;‘) 
let l = l + 1 | call setline(l,‘const int inf=0x3f3f3f3f;‘) 
let l = l + 1 | call setline(l,‘const double pi=4.0*atan(1.0);‘) 
let l = l + 1 | call setline(l,‘const int mod=1000000007;‘) 
let l = l + 1 | call setline(l,‘const double EXP=1e-8;‘) 
let l = l + 1 | call setline(l,‘const double E=exp(1.0);‘) 
let l = l + 1 | call setline(l,‘‘) 
let l = l + 1 | call setline(l,‘int main()‘) 
let l = l + 1 | call setline(l,‘{‘) 
let l = l + 1 | call setline(l,‘    //freopen("in.txt","r",stdin);‘) 
let l = l + 1 | call setline(l,‘    //freopen("out.txt","w",stdout);‘) 
let l = l + 1 | call setline(l,‘    ‘) 
let l = l + 1 | call setline(l,‘    return 0;‘) 
let l = l + 1 | call setline(l,‘}‘) 
endfunc  

"进行版权声明的设置
"添加或更新头
map <F4> :call TitleDet()<cr>‘s
function AddTitle()
    call append(0,"/*=============================================================================")
    call append(1,"#")
    call append(2,"# Author: wust_HLD")
    call append(3,"#")
    call append(4,"# E-mail:wustcoder@163.com")
    call append(5,"#")
    call append(6,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
    call append(7,"#")
    call append(8,"# Filename: ".expand("%:t"))
    call append(9,"#")
    call append(10,"# Description: http://www.cnblogs.com/I-love-HLD/")
    call append(11,"#")
    call append(12,"=============================================================================*/")
    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endf
"更新最近修改时间和文件名
function UpdateTitle()
    normal m‘
    execute ‘/# *Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@‘
    normal ‘‘
    normal mk
    execute ‘/# *Filename:/s@:.*$@\=":\t\t".expand("%:t")@‘
    execute "noh"
    normal ‘k
    echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
"判断前10行代码里面,是否有Last modified这个单词,
"如果没有的话,代表没有添加过作者信息,需要新添加;
"如果有的话,那么只需要更新即可
function TitleDet()
    let n=1
    "默认为添加
    while n < 10
        let line = getline(n)
        if line =~ ‘^\#\s*\S*Last\smodified:\S*.*$‘
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction
View Code

 

我的VIM。。。

标签:

原文地址:http://www.cnblogs.com/I-love-HLD/p/4414293.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!