set nu
set nocompatible
filetype on
filetype indent on
syntax on
set tabstop=4
set shiftwidth=4
set noexpandtab
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set history=1000
inoremap jk <Esc>
网络上的其他方案
"Section I. General configuration
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set autoindent
set smartindent
set cindent
set ai
set nu
"set path+=/usr/include/c++/11
syntax enable
"syntax on
colorscheme desert
"set mouse=a
set colorcolumn=80
set cmdheight=2
set number
set ruler
"Allow backspace move out of one line, indent, insert position
set backspace=eol,start,indent
"Allow <--> h l to move out of one line
set whichwrap+=<,>,h,l
"Ignore cases' different when searching
set incsearch
"Jump to the matched pair shortly when typing ({[]})
set showmatch
"Hightlight the searching result
set hlsearch
"Show the status bar even for single window
set laststatus=2
"Keep the remaining lines for margins of upside and downside
set scrolloff=10
"Following are settled for vimgdb
":run macros/gdb_mappings.vim
":set asm=0
":set gdbprg=/usr/bin/gdb
:map <F8> :bel 30vsplit gdb-variables<cr>
:map <F9> :close<Esc>
map <c-w><c-f> :FirstExplorerWindow<cr>
map <c-w><c-b> :BottomExplorerWindow<cr>
map <c-w><c-t> :WMToggle<cr>
:map <F6> :WMToggle<cr>
"Section II: Tags and Auto completion:
filetype plugin indent on
set completeopt=longest,menu
map <C-I> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"Section III: SuperTab for completion:
"Type2: Remember last type untill ESC
"Type1: Remember last type unless it is changed manually
"Type0: Don not remember
let g:SuperTabRetainComppletionType=2
" <C-X><C-O>: coding format
" <C-X><C-K>: writing format
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
"Section IV: Window explorer:
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let g:winManagerWindowLayout="FileExplorer|TagList"
" FIXME(liuyong): Make it a configurable template
" let g:clang_debug = 1
let g:clang_debug = 0
let g:clang_library_path = "/usr/lib/llvm-10/lib"
let g:clang_user_options = "-std=c++14"
nmap wm :WMToggle<cr>
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
"Section V: Quick find:
nnoremap <silent> <F2> :Grep<cr>
"Section VI: Automatic match
":inoremap ( ()<ESC>i
"
":inoremap ) <c-r>=ClosePair(')')<CR>
"
":inoremap { {}<ESC>i
"
":inoremap } <c-r>=ClosePair('}')<CR>
"
":inoremap [ []<ESC>i
"
":inoremap ] <c-r>=ClosePair(']')<CR>
inoremap jk <Esc>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
autocmd FileType python setlocal et sta sw=2 sts=2
syntax match long_line_warning "^.\{80,}$"
highlight link long_line_warning Error