vim脚本配置

俗话说的好工欲善其事 必先利其器,今天就跟大家分享下我的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,latin1
endif

set autoindent
set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set ignorecase
set incsearch

set 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 file
set viminfo='20,/"50    " read/write a .viminfo file, don't store more
            " than 50 lines of registers
set history=50      " keep 50 lines of command line history
set ruler       " show the cursor position all the time

" Only do this part when compiled with support for autocommands
if 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'/"" |
  / endif
endif

if 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 csverb
endif

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

filetype plugin on

if &term=="xterm"
     set t_Co=8
     set t_Sb=^[[4%dm
     set t_Sf=^[[3%dm
endif

" Don't wake up system with blinking cursor:
http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值