【Gvim】Ubuntu下Gvim设定技巧

在编辑->启动设定中设定如下启动参数:

set nocompatible 
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 
colorscheme murphy

其中第一行设定不兼容vi,可以使用更多新增命令

第二行设定文件编码

第三行设定全局配色方案

一个典型的启动脚本

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
colorscheme murphy
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '/<cmd'
let cmd = '""' . $VIMRUNTIME . '/diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '/diff"'
endif
else
let cmd = $VIMRUNTIME . '/diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

分析如下

"一般设置.
set nocompatible "VIM而不是VI
set history=50 "历史记录50条
set fenc=utf-8 "设置默认语言为8位unicode
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
"man Q gq "屏蔽Q, 以免进入Ex模式
filetype on "打开文件类型检测

"颜色设置.
colorscheme murphy "主题
syntax on "语法高亮

"界面设置.
set ruler "显示当前位置
set number "显示行号
"set nonumber "不显示行号

"格式设置.
"set autoindent "自动缩进
set smartindent "智能缩进
"set cindent "C缩进
"set tabstop=4 "硬TAB
"set softtabstop=4 "软TAB
set shiftwidth=4 "缩进空格数
set expandtab "空格替换TAB
"set smarttab "智能TAB
"
set showmatch "显示匹配
set matchtime=5 "1/10秒延迟
set hlsearch "高亮搜索
set incsearch "搜索中匹配

posted @ 2012-12-16 14:21  牧之丨  阅读(1027)  评论(0编辑  收藏  举报