Vim 学习笔记

Vim配置文件

Alex_yan posted @ 2008年11月06日 23:23 in Vim , 1111 阅读

"if v:progname =~? "evim"
" finish
"endif

" 禁止兼容模式
set nocompatible

" 设置<BS>可以删除的字符
set backspace=indent,eol,start

" 除了VMS系统外 覆盖文件时保留备份
if has("vms")
set nobackup       
else
set backup       
endif

set history=50        " 保存50个命令历史
set ruler        " 始终显示当前位置
set showcmd        " 显示未完成的命令
set incsearch        " 输入搜索时显示匹配

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" 不使用Ex模式, 将Q映射
map Q gq

" In many terminal emulators the mouse works just fine, thus enable it.
set mouse=a

" 颜色数目大于2 或在 GUI 的情况下运行时
" 开启语法高亮与查找模式匹配
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif

" 如果支持自动命令
if has("autocmd")

" 允许文件类型探测.
" 使用文件类型相关的插件
" 'cindent' is on in C files, etc.
" 使用缩进文件.
filetype plugin indent on

" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!

" 一行长于78字符时自动换行.
autocmd FileType text setlocal textwidth=78

" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

augroup END

else

set autoindent        " always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
         \ | wincmd p | diffthis

//输入括号或引号后 光标自动移到括号中
:inoremap () ()<Left>
:inoremap [] []<Left>
:inoremap "" ""<Left>

//在插入模式中使用Ctrl-x 来控制光标
:inoremap <C-H> <Left>
:inoremap <C-L> <Right>
:inoremap <C-J> <Down>
:inoremap <C-K> <Up>

//颜色主题
:colorscheme darkblue


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter