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

Vim配置

时间:2015-08-07 14:45:12      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:vim

工欲善其事,必先利其器

好吧,进军Vim啦

留一下配置文件(以后陆续更新):

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





"设置存储路径
cd F:/code



""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""显示相关""""""""""""""""""""""""""""""""""""""""""""""  
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


"windows 下 gvim打开默认全屏显示
autocmd GUIEnter * simalt ~x


"set shortmess=atI   " 启动的时候不显示那个援助乌干达儿童的提示  
"winpos 0 0          " 设定窗口位置  
"set lines=40 columns=155    " 设定窗口大小

"显示行号
set nu


set backspace=indent,eol,start

"语法高亮
syntax on

" 设置配色方案
"colorscheme murphy



"映射F3编译
map <F3> :!g++ -std=c++11 % -o %<<cr>


"映射F4运行
map <F4> :!%<<cr>
"linux 下把上面那行改成下面这一行
"map <F4> :!./%<<cr>


"映射F5 保存CPP文件并直接编译运行
map <F5> :call CompileRunCpp()<CR>
func! CompileRunCpp()
    exec ":w"
    exec "!g++ % -o %<"
    exec "! %<"
endfunc

"映射F6 保存java文件并且编译运行
map <F6> :call JAVA()<CR>
func! JAVA()
    exec ":w"
    exec "!javac %"
    exec "!java %<"
endfunc

"映射F2自动添加头文件等内容
map <F2> :call SetTitle()<CR>
func SetTitle()
    let l = 0
    let l = l + 1 | call setline(l,‘/* **********************************************‘)
    let l = l + 1 | call setline(l,‘    > Auther        :  zzuspy‘)
    let l = l + 1 | call setline(l,‘    > Mail          :  zzuspy@qq.com‘)
    let l = l + 1 | call setline(l,‘    > Created Time  :  ‘.strftime(‘%c‘))
    "let l = l + 1 | call setline(l,‘File Name   : ‘.expand(‘%‘))
    let l = l + 1 | call setline(l,‘*********************************************** */‘)
    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 <list>‘)
    let l = l + 1 | call setline(l, ‘#include <cmath>‘)
    let l = l + 1 | call setline(l, ‘#include <deque>‘)
    let l = l + 1 | call setline(l, ‘#include <queue>‘)
    let l = l + 1 | call setline(l, ‘#include <stack>‘)
    let l = l + 1 | call setline(l, ‘#include <bitset>‘)
    let l = l + 1 | call setline(l, ‘#include <cctype>‘)
    let l = l + 1 | call setline(l, ‘#include <cstdio>‘)
    let l = l + 1 | call setline(l, ‘#include <string>‘)
    let l = l + 1 | call setline(l, ‘#include <vector>‘)
    let l = l + 1 | call setline(l, ‘#include <complex>‘)
    let l = l + 1 | call setline(l, ‘#include <cstdlib>‘)
    let l = l + 1 | call setline(l, ‘#include <cstring>‘)
    let l = l + 1 | call setline(l, ‘#include <fstream>‘)
    let l = l + 1 | call setline(l, ‘#include <sstream>‘)
    let l = l + 1 | call setline(l, ‘#include <utility>‘)
    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 <functional>‘)
    let l = l + 1 | call setline(l, ‘#define LL long long‘)
    let l = l + 1 | call setline(l, ‘#define INF 0x7fffffff‘)
    let l = l + 1 | call setline(l, ‘using namespace std;‘)
    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, ‘   return 0;‘)
    let l = l + 1 | call setline(l, ‘}‘)
endfunc






""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""键盘命令""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 映射全选+复制 ctrl+a
""map <C-A> ggVGY
""map! <C-A> <Esc>ggVGY
""map <F12> gg=G

" 选中状态下 Ctrl+c 复制
vmap <C-c> "+y





""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""实用设置""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 设置当文件被改动时自动载入
set autoread

" 隐藏工具栏
set guioptions-=T  

" 隐藏菜单栏
"set guioptions-=m         

" Tab键的宽度
set tabstop=4

" 统一缩进为4
set softtabstop=4
set shiftwidth=4

" 不要用空格代替制表符
set noexpandtab

" 在行和段开始处使用制表符
set smarttab

" 显示行号
set number

" 历史记录数
set history=1000

"禁止生成临时文件
set nobackup
set noswapfile

"搜索忽略大小写
set ignorecase

"搜索逐字符高亮
set hlsearch
set incsearch

"行内替换
set gdefault

"编码设置
"set enc=utf-8
"set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

"语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn

"自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(‘)‘)<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair(‘}‘)<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(‘]‘)<CR>
:inoremap " ""<ESC>i
:inoremap ‘ ‘‘<ESC>i
function! ClosePair(char)
    if getline(‘.‘)[col(‘.‘) - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endfunction
filetype plugin indent on 

"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu



版权声明:本文为博主原创文章,未经博主允许不得转载。

Vim配置

标签:vim

原文地址:http://blog.csdn.net/u014355480/article/details/47338551

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