" This must be first, because it changes other options as a side effect.
set nocompatible
" sytle
colo torte
" set encoding
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" file format
set fileformats=dos,unix,mac
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" keep a backup file
set backup
" keep 100 lines of command line history
set history=100
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
" do incremental searching
set incsearch
" In many terminal emulators the mouse works just fine, thus enable it.
if has(‘mouse’)
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" backspace in Visual mode deletes selection
vnoremap <BS> d
" CTRL-X and SHIFT-Del are Cut
"vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
"vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
"map <C-V> "+gP
map <S-Insert> "+gP
" set guioptions
"set guioptions-=a
" CTRL-TAB is Next tab
noremap <C-Tab> gt
vnoremap <C-Tab> <esc>gt
inoremap <C-Tab> <esc>gt
" Shift_TAB is Previous tab
noremap <S-Tab> gT
vnoremap <S-Tab> <esc>gT
inoremap <S-Tab> <esc>gT
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
" Don’t use ALT keys for menus.
set winaltkeys=no
" tab mapping
map <M-1> 1gt
map <M-2> 2gt
map <M-3> 3gt
map <M-4> 4gt
map <M-5> 5gt
map <M-6> 6gt
map <M-7> 7gt
map <M-8> 8gt
map <M-9> 9gt
map <M-t> :tabnew<CR>
map <M-w> :bd<CR>
map! <M-1> <esc>1gt
map! <M-2> <esc>2gt
map! <M-3> <esc>3gt
map! <M-4> <esc>4gt
map! <M-5> <esc>5gt
map! <M-6> <esc>6gt
map! <M-7> <esc>7gt
map! <M-8> <esc>8gt
map! <M-9> <esc>9gt
map! <M-t> <esc>:tabnew<CR>
map! <M-w> <esc>:bd<CR>
" display the line number
set number
" smartcase for searching
set ignorecase smartcase
" tab size
set tabstop=2
" 2 space when auto-indent
set shiftwidth=2
" replace tab with space
set expandtab
" linebreak
set linebreak
" linebreak module for asian language
set fo+=mB
" cursor keys wrap to previous/next line
set whichwrap=h,l,~,b,s,<,>,[,]
" auto indent
set autoindent
" When a bracket is inserted, briefly jump to the matching one
set showmatch
" set up statusline
set laststatus=2
set statusline=%<%f %h%m%r%=%k[%{(&fenc=="")?&enc:&fenc}%{(&bomb?",BOM":"")}] [%{&fileformat}] %-14.(%l,%c%V%) %P
"if (has("gui_running"))
" set nowrap
" set guioptions+=b
" colo torte
"else
" set wrap
" colo ron
"endif
" full screen
"au GUIEnter * simalt ~x
" set editor size
let g:editorLines=30
let g:editorColumns=125
" set editor size
function! SetScreenSize()
let &lines=g:editorLines
let &columns=g:editorColumns
endfunction
call SetScreenSize()
" get editor size
function! GetScreenSize()
let g:editorLines=&lines
let g:editorColumns=&columns
endfunction
" full screen
let g:fullScreened = 0
function! Fullscreen()
if g:fullScreened == 0
call GetScreenSize()
let g:fullScreened = 1
simalt ~x
set go-=m
set go-=T
set go-=r
set go-=b
else
let g:fullScreened = 0
call SetScreenSize()
set go+=m
set go+=T
set go+=r
set go+=b
endif
endfunction
map <F11> :call Fullscreen()<CR>
function! SaveSession()
"set sessionoptions-=curdir
"set sessionoptions+=sesdir
mksession! $VIM/session.vim
wviminfo! $VIM/session.viminfo
endfunction
map <F5> :call SaveSession()<CR>
function! LoadSession()
source $VIM/session.vim
rviminfo $VIM/session.viminfo
endfunction
map <F6> :call LoadSession()<CR>
set magic
" don’t highlight search result
map <F2> :noh<CR>
" for bufexplorer
map <F3> be
map! <F3> <esc>be
" share clipborad with windows
set clipboard+=unnamed
"When _vimrc is edited, reload it
autocmd! bufwritepost _vimrc source $VIM/_vimrc