VIM配置文件记录

vimrc-vim的环境配置文件,包括vim操作的option和setting

 

set nocompatible
set magic

"Display related
set ru "标尺信息
set sm
set hlsearch
syntax on
set is "start searching when you are typing
set go=m
set guioptions+=r
set guioptions+=t
"set guioptions+=T
set guioptions+=e
set showmode
set dy=lastline "显示最多行,不用@@
"以上是缩进相关
set ambiwidth=double
set columns=90
set background=dark
set ai "auto indent
set si "smart indent
set nu "show line number
set ruler
colo torte

"Enable folding
set nofen
set fdl=0

"Misc
set wildmenu
"No sound on errors
set noerrorbells
set novisualbell
set t_vb=

"TAB RELATED
set sw=4
set ts=4
set smarttab
set et

"Editing related
set backspace=indent,eol,start
set whichwrap=h,l,~,b,s,<,>,[,]
"默认情况下, 在 VIM 中当光标移到一行最左边的时候, 我们继续按左键, 光标不能回到上一行的最右边。 同样地, 光标到了一行最右边的时候, 我们不能通过继续按右跳到下一行的最左边。 通过设置 whichwrap 我们可以对一部分按键开启这项功能。
set mouse=a "the mouse is enabled all the time
set selectmode=
set mousemodel=popup
"set keymodel=
set selection=inclusive

set showmatch

"file type related
filetype plugin indent on
"set to auto read when a file is changed from the outside
set autoread

"中文问题
" 环境:Windows XP SP2,gVIM 7.1
set encoding=utf-8
langua message zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/menu.vim
" Encoding related
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" encoding 是 utf-8 的时候可以设置 guifontwide
" 这样中英文就可以用不同的字体了,下面是我感觉舒服的配置
set guifont=Bitstream_Vera_Sans_Mono:h12:cANSI
set guifontwide=新宋体:h12
set linespace=8
" PS: Bitstream 是 Linux 中挖出来的,漂亮的反锯齿

"help file set to cn
if version >= 603
set helplang=cn
endif
set stal=1
set nobackup

autocmd BufReadPost * if line("'/"")&& line ("'/"") <= line("$") | exe "normal `/"" | endif
autocmd BufEnter * call DoWordComplete()

"断行设置
set tw=78
set lbr
set fo+=mB

"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 <C-t> :tabnew<CR>
map <C-w> :tabclose<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! <C-t> <esc>:tabnew<CR>
map! <C-w> <esc>:tabclose<CR>
set guitablabel=%N// %t/ %M

" 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>
"2006-09-13 如下:保存视图
au BufWinLeave *.ztx mkview
au BufWinEnter *.ztx silent loadview
au BufNewFile,BufRead *.tx1 setf tx1

" 浏览
autocmd BufEnter * lcd %:p:h " 放入.vimrc自动完成上面的命令
"autocmd :Ex:q

" ============================================================================
" Shortcuts
" ============================================================================
" Move lines
nmap <C-Down> :<C-u>move .+3<CR>
nmap <C-Up> :<C-u>move .-2<CR>

imap <C-Down> <C-o>:<C-u>move .+1<CR>
imap <C-Up> <C-o>:<C-u>move .-2<CR>

vmap <C-Down> :move '>+1<CR>gv
vmap <C-Up> :move '<-2<CR>gv

" Toggle line number,display the line number on the left
nmap <C-F12> :setlocal nu!<CR>
imap <C-F12> <C-o>:setlocal nu!<CR>

" Toggle spell check, open or close spell check
" For VIM7 only
nmap <C-F11> :setlocal spell!<CR>
imap <C-F11> <C-o>:setlocal spell!<CR>

"简单编辑更新 _vimrc文件
nmap ,v :e C:/Program Files/Vim/_vimrc<CR>

nmap ,fe :Texplore<CR>

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

" 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-PageDown>w
inoremap <C-Tab> <C-O><C-PageDown>w
cnoremap <C-Tab> <C-C><C-PageDown>w
onoremap <C-Tab> <C-C><C-PageDown>w

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

" 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-C and CTRL-Insert are Copy
vnoremap <C-C> "+y

" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x

"Map space to /
"wmap <space> /

"Map auto complete of (, ", ', [
inoremap $1 ()<esc>:let leavechar=")"<cr>i
inoremap $2 []<esc>:let leavechar="]"<cr>i
inoremap $4 {<esc>o}<esc>:let leavechar="}"<cr>O
inoremap $3 {}<esc>:let leavechar="}"<cr>i
inoremap $q ''<esc>:let leavechar="'"<cr>i
inoremap $w ""<esc>:let leavechar='"'<cr>i
au BufNewFile,BufRead *./(vim/)/@! inoremap " ""<esc>:let leavechar='"'<cr>i
au BufNewFile,BufRead *./(txt/)/@! inoremap ' ''<esc>:let leavechar="'"<cr>i
imap <m-l> <esc>:exec "normal f" . leavechar<cr>a
imap <d-l> <esc>:exec "normal f" . leavechar<cr>a

"=============================================================================
" Modes
"=============================================================================

function EnglishMode()
set imactivatekey=
set noimcmdline
set iminsert=0
set imsearch=0
setlocal spell
endfunction
command -nargs=0 EMODE call EnglishMode()

function ChineseMode()
set imactivatekey=C-space
set noimcmdline
set iminsert=2
set imsearch=2
setlocal nospell
endfunction
command -nargs=0 CMODE call ChineseMode()

function TextMode()
setlocal nocin
setlocal nosm
setlocal noai
setlocal tw=78
endfunction
command -nargs=0 TMODE call TextMode()

function CodeMode()
setlocal cin
setlocal sm
setlocal ai
setlocal tw=78
endfunction
command -nargs=0 CODEMODE call CodeMode()

"FencView Setting
let g:fencview_autodetect=0

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General Abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iabbrev DME the Department of Mechanical Engineering
iabbrev Thu Tsinghua
iabbrev THU Tsinghua
iabbrev MC Max CHEN
iabbrev MDATE <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值