vim配置

linux下的vim个性化配置

" set default encoding
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936

" set color
colorscheme desert

" set gui font
set guifont=Bitstream\ Vera\ Sans\ Mono\ 10

" use vim to key in
set nocompatible

" set the rows of history
set history=100

" pop window to confirm if the change
set confirm

" set clipboard shared with window sys
set clipboard+=unnamed

" listen filetype
filetype on

" loading file plugin
filetype plugin on

" set indent for special file
filetype indent on

" save global var
set viminfo+=!

" not be spilt row when having keyword as follow
set iskeyword+=_,$,@,%,#,-

" set programmer highlight
syntax on

" show highlight for keywords
syntax keyword gtkType gint gshort guint gushort gulong gdouble gfloat gchar guchar gboolean gpointer
highlight link gtkType Type


" highlight for char which over 100limited
" highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
" match OverLength '\%101v.*'

" the color of the status line
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White

" file settings
" set backup file
set nobackup

" not create swap file
setlocal noswapfile
set bufhidden=hide

set linespace=0

" auto completed opr in enhanced command
set wildmenu

" show the row and col at the position which mouse focused on
set ruler
set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%)

" the row high in cmd
set cmdheight=2

" use backspace keyboard to deal with those which ard indent, eol, start,etc.
set backspace=2

" allow backspace cross wide
set whichwrap+=<,>,h,l

" could use mouse at buffer in any where
set mouse=a
set selection=exclusive
set selectmode=mouse,key

" not show help whern started
set shortmess=atI

" tell us which row has been modified
set report=0

" set not bell sound by using vim keyboard
set noerrorbells

" show blank when splited window
set fillchars=vert:\ ,stl:\ ,stlnc:\


" show highlight for the matched word
set showmatch

" the time of the highlight which have been matched
set matchtime=5

" ignore case
set ignorecase

" not show the row which the search keyword in
set nohlsearch

" highlight for search keyword when finding keyword
set incsearch

" input :set list cmd to be seen what should be shown
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$

" keep 3 row between the buffer of the top and the bottom
set scrolloff=3

" not bell
set novisualbell

" the content of the status lines
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}

" show status line
set laststatus=2

" auto format
set formatoptions=tcrqn

" extend prev row indent,special for multi row comments
set autoindent

" if c program then auto indent
set smartindent

" use c indent
set cindent

" tab for 4 chars
set tabstop=4

" indent for 4 blank
set softtabstop=4
set shiftwidth=4

" not use tab to replace blank
set noexpandtab

" not change row
set nowrap

" sorted by name
let Tlist_Sort_Type = "name"

let Tlist_Use_Right_Window = 1

let Tlist_Compart_Format = 1

let Tlist_Exist_OnlyWindow = 1

let Tlist_File_Fold_Auto_Close = 0

let Tlist_Enable_Fold_Column = 0


" Autocommands
if has("autocmd")
	autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number
	autocmd FileType xml,html vmap  'o'>o-->
	autocmd FileType java,c,cpp,cs vmap  ''>o*/
	autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100
	autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim
				\ if line("'\"") > 0 && line("'\"") <= line("{1}quot;) |
				\   exe "normal g`\"" |
				\ endif
endif " has("autocmd")

" use F5 to compile and run c program
" use F6 to compile and run c++ program
" if use in window then should be remove './'
" used for c
map  :call CompileRunGcc()
func! CompileRunGcc()
	exec "w"
	exec "!gcc % -o %<"
	exec "! ./%<"
endfunc

" used for c++
map  :call CompileRunGpp()
func! CompileRunGpp()
	exec "w"
	exec "!g++ % -o %<"
	exec "! ./%<"
endfunc


" show more clearly in .NFO file
set encoding=utf-8
function! SetFileEncodings(encodings)
	let b:myfileencodingsbak=&fileencodings
	let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
	let &fileencodings=b:myfileencodingsbak
	unlet b:myfileencodingsbak
endfunction

au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()

" show highlight for txt or vim file
au BufRead,BufNewFile *  setfiletype txt

" use black keyboard to expand
set foldenable
"set foldmethod=manual
set foldmethod=syntax
set foldlevel=100
nnoremap  @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')

" set minibufexpl plugin
" let g:miniBufExplMapWindowNavVim = 1
" let g:miniBufExplMapWindowNavArrows = 1
" let g:miniBufExplMapCTabSwitchBufs = 1
" let g:miniBufExplModSelTarget = 1

" set mapleader
let mapleader = ","

" use 'ss' to load .vimrc
map  ss :source ~/.vimrc

" use 'ee' to open .vimrc file quickly
map  ee :e ~/.vimrc

" use 'w' save file
map  w :w

" use 'wq' to save and quit file quickly
map  wq :wq

" auto source .vimrc and make it effect
autocmd! bufwritepost .vimrc source ~/.vimrc

参考文档

https://www.linode.com/docs/tools-reference/tools/introduction-to-vim-customization/
https://vimconfig.com/

你可能感兴趣的:(工作文档参考)