vim配置

以下是我的vim git地址 https://github.com/kotomifi/my_vim

使用模板

autocmd BufNewFile *.go 0r ~/.vim/template/go.tpl " golang
autocmd BufNewFile *.sh 0r ~/.vim/template/sh.tpl " shell

这样在使用vim创建文件的时候就会默认添加模板中的内容

快速运行

autocmd filetype python nnoremap <F4> :w <bar> exec '!python '.shellescape('%')<CR>
autocmd filetype go nnoremap <F4> :w <bar> exec '!go run ' .shellescape('%')<CR>
autocmd filetype c nnoremap <F4> :w <bar> exec '!gcc '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
autocmd filetype cpp nnoremap <F4> :w <bar> exec '!g++ '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>

替换ECS

inoremap jk <esc>

主题配置

这里使用monokai主题,这个主题和sublime比较接近。
安装步骤如下:

git clone https://github.com/sickill/vim-monokai.git
mv vim-monokai/colors ~/.vim/

# 编辑~/.vimrc文件,添加如下内容
syntax enable
colorscheme monokai

个性配置

set nu                     " 显示行号
set tabstop=4              " tab为四个空格
set shiftwidth=4
set expandtab              " 使用空格替换tab
set cursorline
set numberwidth=4
set autoindent             " 自动换行
set ignorecase             " 搜索忽略大小写
set noswapfile             " 异常退出时不产生.swap文件
set nobackup
set cmdheight=1
set nocompatible
filetype plugin on

编码设置

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8

推荐几个常用的插件

Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-surround'
Plugin 'bling/vim-airline'
Plugin 'altercation/vim-colors-solarized'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'davidhalter/jedi-vim'
Plugin 'tpope/vim-commentary'
Plugin 'kien/ctrlp.vim'
Plugin 'vim-scripts/taglist.vim'
Plugin 'fatih/vim-go'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'
Plugin 'nsf/gocode', {'rtp': 'vim/'}

这里的插件是是用bundle管理的。

posted @ 2015-12-14 22:58  leesea  阅读(282)  评论(0)    收藏  举报