1 syntax enable
2 syntax on
3
4 colorscheme desert
5
6 set nocompatible
7 set filetype=c
8
9 set number
10 set numberwidth=4
11
12 set wrap " 自动换行
13
14 set autoindent
15 set smartindent
16 set cindent
17 set ai!
18
19 set smarttab " 在行和段开始处使用制表符
20
21 set cursorline " 高亮显示当前行
22 "set expandtab
23 set noexpandtab " 不要用空格来代替制表符tab
24 set tabstop=8
25 set shiftwidth=8
26 set softtabstop=8
27
28 set mouse=a
29
30 set showmatch " 高亮显示匹配的括号
31 set history=1000
32 set hlsearch " 高亮被搜索的句子
33 set incsearch
34 set nowrapscan " 禁止搜索到文件两端时重新搜索
35
36 set gdefault
37
38
39 set diffexpr=MyDiff()
40
41 function MyDiff()
42 let opt = '-a --binary '
43 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
44 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
45 let arg1 = v:fname_in
46 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
47 let arg2 = v:fname_new
48 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
49 let arg3 = v:fname_out
50 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
51 let eq = ''
52 if $VIMRUNTIME =~ ' '
53 if &sh =~ '\<cmd'
54 let cmd = '""' . $VIMRUNTIME . '\diff"'
55 let eq = '"'
56 endfunction
57
58 " 启动最大化
59 if has('gui_running') && has("win32")
60 au GUIEnter * simalt ~x
61 endif
62
63 "////////////////////////////////////////////////////////////////////////////////////////
64 "文件显示编码
65 set fileencodings=utf-8,gbk2312,gbk,gb18030,cp936
66 set encoding=utf-8
67 set termencoding=utf-8
68 set fileencoding=utf-8
69 set imcmdline
70
71
72
73 " 解决菜单乱码
74 "-----------------------------------
75 set langmenu=zh_CN
76 let $LANG = 'zh_CN.UTF-8'
77 source $VIMRUNTIME/delmenu.vim
78 source $VIMRUNTIME/menu.vim
79
80 source $VIMRUNTIME/vimrc_example.vim
81 source $VIMRUNTIME/mswin.vim
82 behave mswin
83 "-----------------------------------
84
85 "////////////////////////////////////////////////////////////////////////////////////////
86 "vim 提示信息乱码解决方法
87 "language messages zh_CN.UTF-8
88 if has("win32")
89 set termencoding=chinese
90 language message zh_CN.UTF-8
91 endif
92
93
94 " 多标签
95 "let Tlist_Ctags_Cmd='D:\Vim\vim73\ctags.exe'
96 let Tlist_Ctags_Cmd='ctags.exe'
97 set autochdir
98 set tags=tags; " ';' 不能没有
99
100 let Tlist_Auto_Open=1 " Auto Open when VIM opening
101 let Tlist_Show_One_File=1 " 只显示当前文件的标签
102 let Tlist_Exit_OnlyWindow=1 " 当只有 Tlist 窗口时关闭
103 let Tlist_Use_Right_Window=0 " 窗口在右边 = 1
104 "let Tlist_Show_Menu=1 "显示taglist菜单
105 "let Tlist_File_Fold_Auto_Close=1 "让当前不被编辑的文件的方法列表自动折叠起来
106
107
108 " 窗口管理
109 "let g:winManagerWindowLayout='FileExplorer|TagList'
110 let g:winManagerWindowLayout='FileExplorer' " 各单独一个窗口, 一屏可以观察更多
111 "let g:winManagerWindowLayout='TagList|FileExplorer,BufExplorer'
112 "let g:winManagerWindowLayout='FileExplorer|BufExplorer'
113 nmap wm :WMToggle<cr>
114
115
116 " 多文件编辑
117 "ctrl+Tab,切换到前一个buffer,并在当前窗口打开文件;
118 "ctrl+shift+Tab,切换到后一个buffer,并在当前窗口打开文件;
119 "ctrl+箭头键,可以切换到上下左右窗口中;
120 "ctrl+h,j,k,l,切换到上下左右的窗口中。
121 let g:miniBufExplMapCTabSwitchBufs=1
122 let g:miniBufExplMapWindowsNavVim=1
123 let g:miniBufExplMapWindowNavArrows=1
124
125 "快速切换头文件与源文件, 按F12即可以在c/h文件中切换,也可以通过输入:A实现
126 nnoremap <silent> <F12> :A<CR>
127
128 "工程中快速查找, F3 快捷键, 然后支持正则表达式
129 nnoremap <silent> <F3> :Grep<CR>
130
131
132 " 自动补全
133 filetype plugin indent on
134 set completeopt=longest,menu
135
136 let g:SuperTabRetainCompletionType=2
137 let g:SuperTabDefaultCompletionType="<C-X><C-O>"