修改系统用户Vim的配置
vim /etc/vim/vimrc
修改当前用户Vim配置
vim ~/.vimrc
" 设置字符编码
set fileencoding=utf-8
set fileencodings=utf-8,gb2312,gb18030,latin1
set encoding=utf-8
" Sets how many lines of history VIM has to remember
set history=500
" Set to auto read when a file is changed from the outside
set autoread
" Enable filetype plugins
filetype plugin on
filetype indent on
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on the Wild menu
set wildmenu
" 显示行号
set number
" 语法高亮
syntax on
" Show matching brackets when text indicator is over them
set showmatch
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
set softtabstop=4
" 保持上下缩进一致
set autoindent
" Always show current position
set ruler
" Always show the status line
set laststatus=2
" 高亮显示当前行
set cursorline
" 同一 vim 窗口编辑多个文件时,自动切换到正在编辑的文件
set autochdir
" 自动完成大括号
imap { {<CR>}<Esc>kA<CR>
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
配置F5编译运行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec"w"
if &filetype =='c'
exec"!g++ % -o %<"
exec"!time ./%<"
endfunc