set ts=4 et
set noexpandtab
colorscheme desert
" 搜索忽略大小写
set ignorecase smartcase
" 开启实时搜索功能
set incsearch
" 高亮显示搜索结果
set hlsearch
"关闭vi兼容模式
set nocompatible
" 定义快捷键在结对符之间跳转
nmap <Leader>M %
" 显示行号
set number
" 命令打开文件类型检测功能,它相当于文件类型检测功能的开关
filetype on
" 语法高亮
syntax on
" 自动缩进
set autoindent
set smartindent
set mouse-=a
" table键盘4空格
set tabstop=4
" 当使用移动(shift)命令时移动的字符数
set shiftwidth=4
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,cp936,gb18030,gbk,gb2312,latin-1
" 禁止生成备份文件
set nobackup
set fileformat=unix
" 配色方案
"set background=dark
"colorscheme solarized
"colorscheme molokai
"colorscheme phd
"colorscheme darkblue
colorscheme desert
" 高亮显示当前行/列
set cursorline
"highlight CursorLine cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
"set cursorcolumn
"highlight CursorColumn cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
" vundle 环境设置
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
" vundle 管理的插件列表必须位于 vundle#begin() 和 vundle#end() 之间
call vundle#begin()
Plugin ‘VundleVim/Vundle.vim‘
Plugin ‘scrooloose/nerdtree‘
Plugin ‘altercation/vim-colors-solarized‘
" 插件列表结束
call vundle#end()
filetype plugin indent on
" 使用 NERDTree 插件查看工程文件。设置快捷键,速记:file list
nmap <Leader>fl :NERDTreeToggle<CR>
" 设置 NERDTree 子窗口宽度
let NERDTreeWinSize=22
" 设置 NERDTree 子窗口位置
"let NERDTreeWinPos="right"
let NERDTreeWinPos="left"
" 显示隐藏文件
let NERDTreeShowHidden=1
" NERDTree 子窗口中不显示冗余帮助信息
let NERDTreeMinimalUI=1
" 删除文件时自动删除文件对应 buffer
let NERDTreeAutoDeleteBuffer=1
autocmd FileType des setlocal et sta sw=4 sts=4
autocmd FileType python setlocal et sta sw=4 sts=4
autocmd FileType html setlocal noet sta sw=4 sts=4
autocmd FileType xsl setlocal noet sta sw=4 sts=4
autocmd FileType xml setlocal noet sta sw=4 sts=4
autocmd FileType tpl setlocal noet sta sw=4 sts=4
autocmd FileType php setlocal et sta sw=4 sts=4
autocmd FileType c setlocal et sta sw=4 sts=4
autocmd FileType cpp setlocal et sta sw=4 sts=4
autocmd FileType js setlocal et sta sw=4 sts=4
" 当新建 .h .c .hpp .cpp .mk .sh等文件时自动调用SetTitle 函数
autocmd BufNewFile *.[ch],*.hpp,*.cpp,Makefile,*.mk,*.sh,*.py exec ":call SetTitle()"
" 加入注释
func SetComment()
call setline(1,"/*================================================================")
call append(line("."), "* Copyright (C) ".strftime("%Y")." Baidu.com. All rights reserved.")
call append(line(".")+1, "* ")
call append(line(".")+2, "* File:".expand("%:t"))
call append(line(".")+3, "* Author:yourname")
call append(line(".")+4, "* Date:".strftime("%Y年%m月%d日"))
call append(line(".")+6, "*")
call append(line(".")+7, "================================================================*/")
call append(line(".")+8, "")
call append(line(".")+9, "")
endfunc
" 加入shell,Makefile注释
func SetComment_sh()
call append(line(".")+1, "/*================================================================")
call append(line(".")+2, "* Copyright (C) ".strftime("%Y")." Baidu.com. All rights reserved.")
call append(line(".")+3, "* ")
call append(line(".")+4, "* File:".expand("%:t"))
call append(line(".")+5, "* Author:yourname")
call append(line(".")+6, "* Date:".strftime("%Y年%m月%d日"))
call append(line(".")+7, "*")
call append(line(".")+8, "================================================================*/")
call append(line(".")+9, "")
call append(line(".")+10, "")
endfunc
" 加入python注释
func SetComment_py()
call append(line(".")+1, "#================================================================")
call append(line(".")+2, "# Copyright (C) ".strftime("%Y")." Baidu.com. All rights reserved.")
call append(line(".")+3, "# ")
call append(line(".")+4, "# File:".expand("%:t"))
call append(line(".")+5, "# Author:yourname")
call append(line(".")+6, "# Date:".strftime("%Y年%m月%d日"))
call append(line(".")+7, "#")
call append(line(".")+8, "#================================================================")
call append(line(".")+9, "")
call append(line(".")+10, "")
endfunc
" 定义函数SetTitle,自动插入文件头
func SetTitle()
if &filetype == ‘make‘
call setline(1,"")
call append(line("."),"")
call SetComment_sh()
elseif &filetype == ‘sh‘
call setline(1,"#!/system/bin/sh")
call append(line("."),"")
call SetComment_sh()
elseif &filetype == ‘python‘
call setline(1,"\#!/usr/bin/env python")
call append(line("."), "\# -*- coding: gb18030 -*-")
call SetComment_py()
else
call SetComment()
if expand("%:e") == ‘hpp‘
call append(line(".")+10, "#ifndef _".toupper(expand("%:t:r"))."_H")
call append(line(".")+11, "#define _".toupper(expand("%:t:r"))."_H")
call append(line(".")+12, "#ifdef __cplusplus")
call append(line(".")+13, "extern \"C\"")
call append(line(".")+14, "{")
call append(line(".")+15, "#endif")
call append(line(".")+16, "")
call append(line(".")+17, "#ifdef __cplusplus")
call append(line(".")+18, "}")
call append(line(".")+19, "#endif")
call append(line(".")+20, "#endif //".toupper(expand("%:t:r"))."_H")
elseif expand("%:e") == ‘h‘
call append(line(".")+10, "#pragma once")
elseif &filetype == ‘c‘
call append(line(".")+10,"#include \"".expand("%:t:r").".h\"")
elseif &filetype == ‘cpp‘
call append(line(".")+10, "#include \"".expand("%:t:r").".h\"")
endif
endif
endfunc
set tags=tags;
set autochdir
vim配置