俗话说的好工欲善其事 必先利其器,今天就跟大家分享下我的vi的脚本配置。我用的是f8,配置文件为/etc/vimrc,或者~/.vimrc。我所是说的配置是在F8基础纸上增加的配置。 set autoindent 自动缩进功能,不用每次换行不用动手对齐 set smartindent 智能对齐,对于写c/c++很好 set tabstop=4 set shiftwidth=4 TAB键=4个空格(国际标准呵呵) set ignorecase 搜索不再区分大小写,很多代码大小写穿插来回切换很麻烦,也不容易记忆,这样就方便多了 set incsearch 智能搜索,当搜索单词的时候会根据对应的字母高亮显示,不用全写完才显示,对于搜索长关键字很有帮助,不用怕忘记单词了以上就是简单的vim的几个配置属性,vim的强大大家都是知道的,甚至能用插件做成IDE的模式各人习惯问题,本着简单简洁的原则,最后就留下上面几个简单的设置,不过对偶来说够用了呵呵……另外提及几个比较有用的指令 1)vi -d file1 file2------文件比较功能,很方便2)编辑一个文件的同时打开另一个文件 :sp file 或者 :vsp file 横向和竖向比较,ctrl+w进行文件之间的切换,用于复制比较等还是不错3)函数原型查找、数据结构原型查找,现在一般的vi安装后会自带ctags,用于简单的查找也很方便,在源代码的目录中执行 $ctags -R*,执行完以后会在代码的目录下创建一个tag文件,在阅读代码的时候如果想查找函数的原型、数据的定义直接用ctrl+]跳转,返回用ctrl+t。很简单、很方便。补充俩,跟踪文件:$ 直接到达文件底部:Num 直接到达Num行:0 直接到达顶部在有tag存在下,直接vi -t 函数名字,可以直达文件中的函数位置/**********************************vimrc***************************/if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set fileencodings=utf-8,latin1endifset autoindentset smartindentset tabstop=4set softtabstop=4set shiftwidth=4set ignorecaseset incsearchset nocompatible " Use Vim defaults (much better!)set bs=indent,eol,start " allow backspacing over everything in insert mode"set ai " always set autoindenting on"set backup " keep a backup fileset viminfo='20,/"50 " read/write a .viminfo file, don't store more " than 50 lines of registersset history=50 " keep 50 lines of command line historyset ruler " show the cursor position all the time" Only do this part when compiled with support for autocommandsif has("autocmd") " In text files, always limit the width of text to 78 characters autocmd BufRead *.txt set tw=78 " When editing a file, always jump to the last cursor position autocmd BufReadPost * / if line("'/"") > 0 && line ("'/"") <= line("$") | / exe "normal! g'/"" | / endifendifif has("cscope") && filereadable("/usr/bin/cscope") set csprg=/usr/bin/cscope set csto=0 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverbendif" 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 hlsearchendiffiletype plugin onif &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dmendif" Don't wake up system with blinking cursor:" http://www.linuxpowertop.org/known.phplet &guicursor = &guicursor . ",a:blinkon0"