Aug 24, 2008

我的Gvim配置

"我的.gvimrc 根据win的合成,比较适合win操作,比如CTRL+C or X是拷贝剪切。

set fencs=utf-8,gbk

set guifont=YaHei Consolas Hybrid 11
map ff :!txt2tags -t html % ; opera %<.html<CR>
colorscheme zellner
set whichwrap=b,s,l,h,<,>,[,] "使得h,l可以换行移动
"tab mappings 注释
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-`> :tabnew<CR>
"断行设置
set lbr
set fo+=mB "亚洲语言断行支持
"文本编辑设定
set sw=4 "自动缩进4
set ts=4 "自动缩进4
"图形界面设置


" Set options and add mapping such that Vim behaves a lot like MS-Windows
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2006 Apr 02#

" bail out if this isn't wanted (mrsvim.vim uses this).
if exists("g:skip_loading_mswin") && g:skip_loading_mswin
finish
endif

" set the 'cpoptions' to its Vim default
if 1 " only do this when compiled with expression evaluation
let s:save_cpo = &cpoptions
endif
set cpo&vim

" set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows
behave mswin

" backspace and cursor keys wrap to previous/next line
set backspace=indent,eol,start whichwrap+=<,>,[,]

" 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

cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+

" Pasting blockwise and linewise selections is not possible in Insert and
" Visual mode without the +virtualedit feature. They are pasted as if they
" were characterwise instead.
" Uses the paste.vim autoload script.

exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']

imap <S-Insert> <C-V>
vmap <S-Insert> <C-V>

" Use CTRL-Q to do what CTRL-V used to do
noremap <C-Q> <C-V>

" 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>

" For CTRL-V to work autoselect must be off.
" On Unix we have two selections, autoselect can be used.
if !has("unix")
set guioptions-=a
endif

" CTRL-Z is Undo; not in cmdline though
noremap <C-Z> u
inoremap <C-Z> <C-O>u

" CTRL-Y is Redo (although not repeat); not in cmdline though
noremap <C-Y> <C-R>
inoremap <C-Y> <C-O><C-R>

" Alt-Space is System menu
if has("gui")
noremap <M-Space> :simalt ~<CR>
inoremap <M-Space> <C-O>:simalt ~<CR>
cnoremap <M-Space> <C-C>:simalt ~<CR>
endif

" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG

" CTRL-Tab is Next window
noremap <C-Tab> <C-W>w
inoremap <C-Tab> <C-O><C-W>w
cnoremap <C-Tab> <C-C><C-W>w
onoremap <C-Tab> <C-C><C-W>w

" CTRL-F4 is Close window
noremap <C-F4> <C-W>c
inoremap <C-F4> <C-O><C-W>c
cnoremap <C-F4> <C-C><C-W>c
onoremap <C-F4> <C-C><C-W>c

" restore 'cpoptions'
set cpo&
if 1
let &cpoptions = s:save_cpo
unlet s:save_cpo
endi
" An example for a gvimrc file.
" The commands in this are executed when the GUI is started.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2001 Sep 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.gvimrc
" for Amiga: s:.gvimrc
" for MS-DOS and Win32: $VIM_gvimrc
" for OpenVMS: sys$login:.gvimrc

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty

" set the X11 font to use
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1

set ch=2 " Make command line two lines high

set mousehide " Hide the mouse when typing text

" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>

" Only do this for Vim version 5.0 and later.
if version >= 500

" I like highlighting strings inside C comments
let c_comment_strings=1

" Switch on syntax highlighting if it wasn't on yet.
if !exists("syntax_on")
syntax on
endif

" Switch on search pattern highlighting.
set hlsearch

" For Win32 version, have "K" lookup the keyword in a help file
"if has("win32")
" let winhelpfile='windows.hlp'
" map K :execute "!start winhlp32 -k <cword> " . winhelpfile <CR>
"endif


endif

No comments:

Post a Comment