首页 > 学技术 > 技术网文 > C/C++ > 正文

[精彩] [共享交流]请交出你的vimrc


来源 chinaunix.net kuqin整理

用VIM朋友如果你们愿意的话可以把你们vimrc里的一些常用配置和一些技巧贴出来大家一起共享和学习
以便使我们的vim功能更加强大写程序时更加得心应手
我先来点

基本的缩进和语言加亮

set syntax=on 
set cinoptions+={2,0,p0,t0
set nobackup
set cindent 
set syntax=cpp
set formatoptions=tcqr


自定义文件头

function Mytitle()
call setline(1,"/**********************************************")
call append(line("."),"作者:自己名字")
call append(line(".")+1,"时间:".strftime("%c"))
call append(line(".")+2,"文件名:".expand("%"))
call append(line(".")+3,"描述:")
call append(line(".")+4,"**********************************************/")
endf
map <home> <Esc>:call Mytitle()<CR><Esc>:$<Esc>o      "<home>键可改为你喜欢的按键


K&R式代码格式化

map <F5>   <Esc>:1,$g/^$/d<CR><Esc>gg=G<Esc>gg    "<f5>键可改为你喜欢的按键


增加注解

map <F2>   <Esc><S-$>a<TAB>/**/<Esc>2ha          


如果你原意的话那么就跟贴吧:em02:

[ 本帖最后由 lovesaka 于 2006-9-11 21:27 编辑 ]



 flw2 回复于:2006-09-11 21:14:18

我还不会,我一般就是用那个自带的


 lovesaka 回复于:2006-09-11 21:16:44

不会没关系会用就行了
ctrl+c会吧复制到你的vimrc里
试试效果吧:D


 lovesaka 回复于:2006-09-11 21:19:51

哈哈
大家一起来不如果你觉得好用的就ctrl+c复制下去提高你的VIM效率:em02::em02:
最好给点说明是干什么用的

[ 本帖最后由 lovesaka 于 2006-9-11 21:22 编辑 ]


 safedead 回复于:2006-09-11 21:41:51

学习

我以前只用过这句
set cindent
用来自动缩进和加亮C/C++


 flw 回复于:2006-09-11 21:48:24

我的:
set nobackup

set noswapfile
set helplang=Cn

set autoindent
set cindent

set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab

set foldenable
set fdm=marker

nmap <F5> ^W_^W\|
nmap <F6> ^W=
imap <F5> <ESC>^W_^W\|a
imap <F6> <ESC>^W=a
nmap gF ^Wf

上面是我的 XP 的,Debian 下的 vim 的默认配置是出了名的差,所以就需要多设置几句:
set expandtab

set shiftwidth=4
set tabstop=4
set softtabstop=4
set nobackup
set cindent
set autoindent
set showcmd
set helplang=Cn
set nofoldenable
set noswapfile
set number
set mouse=nv
set hlsearch
set incsearch
set viminfo+=h

set nocp
filetype plugin on

autocmd FileType perl set keywordprg=perldoc\ -f

nmap <F5> ^W_^W\|
nmap <F6> ^W=
imap <F5> <ESC>^W_^W\|a
imap <F6> <ESC>^W=a
nmap gF ^Wf

syntax on

colorscheme evening
hi Normal ctermfg=grey ctermbg=black
hi Visual ctermfg=green ctermbg=black
hi Search term=reverse cterm=standout ctermfg=green  ctermbg=yellow
hi IncSearch term=reverse cterm=standout ctermfg=green ctermbg=yellow
hi PmenuSel ctermbg=Green ctermfg=Yellow


[ 本帖最后由 flw 于 2006-9-11 21:49 编辑 ]


 lovesaka 回复于:2006-09-11 22:12:14

呵呵
连flw老大都拿出了那还说什么大家一起来呀:em02::em02:


 飞灰橙 回复于:2006-09-11 23:06:02

不是我的

!vim
!gvim



 converse 回复于:2006-09-11 23:17:05

最近也在玩儿VIM,唯独让我不是很爽的地方就是好像没有特别强大的函数变量补全功能...哪位有好的插件可以推荐一下,谢谢.

之所以想开始学VIM,有如下原因:1)快捷键用的很爽,2)界面主题很酷,3)现在有时也要在linux下面写代码了,不学会这个工具不行.


 lovesaka 回复于:2006-09-11 23:20:58

我再贴上一个

功能:根椐文件格式加注释你可以自己改一下

function Mycomment()
if &syntax=="cpp" || &syntax=="c"
execute "normal  \<Esc>\<S-$>a\<TAB>/**/\<Esc>2ha"
elseif &syntax=="perl" || &syntax=="sh"
execute "normal \<Esc>\<S-$>a\<TAB>#\<Esc>k\<S-$>"
endif
endf
map <F2> <Esc>:call Mycomment()<CR><Esc>:$<Esc>o



 lovesaka 回复于:2006-09-11 23:31:53

我很没用过插件的:(
VIM网站上可能有吧
是呀VIM里函数变量补全功能很爽加上tags那真是爽得不得了


 sttty 回复于:2006-09-11 23:32:54

路过...


 gawk 回复于:2006-09-12 08:40:29

不错,vim弄了一段时间,由于出差中断了,现在看见了这个帖子,真是亲切啊


 chzht001 回复于:2006-09-12 09:10:24

哈哈,收藏了先!!!


 slay78 回复于:2006-09-12 09:13:25

我的太长了,忘记从哪儿抄来的了

" vim:shiftwidth=2:tabstop=8:expandtab

if has('autocmd')
  " Remove ALL autocommands for the current group
  au!

  " Mark .asm files MASM-type assembly
  au BufNewFile,BufReadPre *.asm let b:asmsyntax='masm'
endif

if has('gui_running')
  let do_syntax_sel_menu=1
endif

if has('gui_running') && $LANG !~ '\.'
  set encoding=utf-8
endif

set nocompatible
source $VIMRUNTIME/vimrc_example.vim

set autoindent
set nobackup
set showmatch
set formatoptions+=mM
set fileencodings=ucs-bom,utf-8,gbk
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
if has('mouse')
  set mouse=a
endif
if has('multi_byte') && v:version > 601
  if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
    set ambiwidth=double
  endif
endif

" Key mappings to ease browsing long lines
noremap  <C-J>       gj
noremap  <C-K>       gk
noremap  <Down>      gj
noremap  <Up>        gk
inoremap <Down> <C-O>gj
inoremap <Up>   <C-O>gk

" Key mappings for quick arithmetic inside Vim
nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$
vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$
nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$
vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap

" Key mapping to stop the search highlight
nmap <silent> <F2>      :nohlsearch<CR>
imap <silent> <F2> <C-O>:nohlsearch<CR>

" Key mapping for the taglist.vim plugin
nmap <F9>      :Tlist<CR>
imap <F9> <C-O>:Tlist<CR>

" Key mappings for the quickfix commands
nmap <F11> :cn<CR>
nmap <F12> :cp<CR>

" Non-GUI setting
if !has('gui_running')
  " Do not increase the windows width in the taglist.vim plugin
  if has('eval')
    let Tlist_Inc_Winwidth=0
  endif

  " Set text-mode menu
  if has('wildmenu')
    set wildmenu
    set cpoptions-=<
    set wildcharm=<C-Z>
    nmap <F10>      :emenu <C-Z>
    imap <F10> <C-O>:emenu <C-Z>
  endif
endif

if has('autocmd')
  function! SetFileEncodings(encodings)
    let b:my_fileencodings_bak=&fileencodings
    let &fileencodings=a:encodings
  endfunction

  function! RestoreFileEncodings()
    let &fileencodings=b:my_fileencodings_bak
    unlet b:my_fileencodings_bak
  endfunction

  function! CheckFileEncoding()
    if &modified && &fileencoding != ''
      exec 'e! ++enc=' . &fileencoding
    endif
  endfunction

  function! ConvertHtmlEncoding(encoding)
    if a:encoding ==? 'gb2312'
      return 'gbk'              " GB2312 imprecisely means GBK in HTML
    elseif a:encoding ==? 'iso-8859-1'
      return 'latin1'           " The canonical encoding name in Vim
    elseif a:encoding ==? 'utf8'
      return 'utf-8'            " Other encoding aliases should follow here
    else
      return a:encoding
    endif
  endfunction

  function! DetectHtmlEncoding()
    if &filetype != 'html'
      return
    endif
    normal m`
    normal gg
    if search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html; charset=[-A-Za-z0-9_]\+">') != 0
      let reg_bak=@"
      normal y$
      let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')
      let charset=ConvertHtmlEncoding(charset)
      normal ``
      let @"=reg_bak
      if &fileencodings == ''
        let auto_encodings=',' . &encoding . ','
      else
        let auto_encodings=',' . &fileencodings . ','
      endif
      if charset !=? &fileencoding &&
            \(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding == '')
        silent! exec 'e ++enc=' . charset
      endif
    else
      normal ``
    endif
  endfunction

  function! GnuIndent()
    setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
    setlocal shiftwidth=2
    setlocal tabstop=8
  endfunction

  function! RemoveTrailingSpace()
    if $VIM_HATE_SPACE_ERRORS != '0' &&
          \(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')
      normal m`
      silent! :%s/\s\+$//e
      normal ``
    endif
  endfunction

  " Highlight space errors in C/C++ source files (Vim tip #935)
  if $VIM_HATE_SPACE_ERRORS != '0'
    let c_space_errors=1
  endif

  " Use Canadian spelling convention in engspchk (Vim script #195)
  let spchkdialect='can'

  " Show syntax highlighting attributes of character under cursor (Vim
  " script #383)
  map <Leader>a :call SyntaxAttr()<CR>

  " Automatically find scripts in the autoload directory
  au FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'

  " File type related autosetting
  au FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4
  au FileType diff  setlocal shiftwidth=4 tabstop=4
  au FileType html  setlocal autoindent indentexpr=
  au FileType changelog setlocal textwidth=76

  " Text file encoding autodetection
  au BufReadPre  *.gb               call SetFileEncodings('gbk')
  au BufReadPre  *.big5             call SetFileEncodings('big5')
  au BufReadPre  *.nfo              call SetFileEncodings('cp437')
  au BufReadPost *.gb,*.big5,*.nfo  call RestoreFileEncodings()
  au BufWinEnter *.txt              call CheckFileEncoding()

  " Detect charset encoding in an HTML file
  au BufReadPost *.htm* nested      call DetectHtmlEncoding()

  " Recognize standard C++ headers
  au BufEnter /usr/include/c++/*    setf cpp
  au BufEnter /usr/include/g++-3/*  setf cpp

  " Setting for files following the GNU coding standard
  au BufEnter /usr/*                call GnuIndent()

  " Remove trailing spaces for C/C++ and Vim files
  au BufWritePre *                  call RemoveTrailingSpace()
endif
"me add
"autocmd BufNewFile *.c exec append(0,"/*   */")|exec append(1,"#include <stdio.h>") |exec append(2,"int main(void)")|exec append(3,"{")|exec append(5,"        return 0;")|exec append(6,"}")| exec ':0'
autocmd BufNewFile *.c exec append(0,"#include <stdio.h>") |exec append(1,"int main(void)")|exec append(2,"{")|exec append(4,"        return 0;")|exec append(5,"}")| exec ':4'
autocmd BufNewFile *.pl exec append(0,"#!/usr/bin/perl -w") | exec append(1,"use strict;") | exec append(2,"use warnings;") | exec ':$'
"autocmd BufNewFile *.py 0r ~/.vim/skeleton/skeleton.py
map <F3> ^i#<ESC>
map <F2> ^x
set viminfo='200,\"500
set history=500
set number




 lowmer 回复于:2006-09-12 09:13:28

set nocompatible
set nobackup
set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set ai

set foldmethod=syntax "按照语法折叠代码,indent为按照缩进折叠代码,zi命令打开/关闭所有折叠
set foldcolumn=3  "设置折叠区域的宽度
set foldclose=all "设置为自动关闭折叠

''对于安装了中文help有效
if version >= 603 
set helplang=cn
endif

source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
source $vimruntime/colors/darkblue.vim  ''设置配色方案
behave mswin

''默认配置
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
  if &sh =~ '\<cmd'
    silent execute '!""C:\Program Files\Vim\vim64\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . '"'
  else
    silent execute '!C:\Program" Files\Vim\vim64\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  endif
endfunction

"设置F5为不同文件类型添加注释
filetype plugin indent on 
autocmd FileType cpp,java  map <F5> 0i//<Esc>
autocmd FileType c  map! <F5> /* */<Esc>
autocmd FileType sh map! <F5> 0i#<Esc>

''设置F12为运行python程序,运行前需要保存
map <F12> :!c:\python24\python.exe % <CR>

[ 本帖最后由 lowmer 于 2006-9-12 17:25 编辑 ]


 er 回复于:2006-09-12 09:35:21

学习


 xnkjdx1998 回复于:2006-09-12 10:30:41

在这里学到很多,不过有个建议,如果各位能在配置时带上点注释会更好,
谢谢


 lovesaka 回复于:2006-09-12 11:30:39

to: slay78,lowmer
谢谢两位大侠能把自己的东西拿来共享从两位贴出来的脚本中自己也偷学了不少东西以前有点不怎么会的也给弄明白了,而且找从中找到了更加简洁的方法来实现自己想要的功能,其实是不是自己亲手写的都无所谓只要你平常觉得好用的就行了,更重要的是你能拿来让大家分享让以免别人写好了的东西自己再写一次,再一个就是能够从别人的东西里吸取很多比较好自己又不知道的知识
to: xnkjdx1998
我想这里再讲什么基本VIM用法那就不必要了不过你的提议不错最好一个功能加上说明也让大家知道是干什么用的
大家继续.........


 gawk 回复于:2006-09-12 12:36:10

function Mycomm()

let  tmphehe=getline(".")
call setline(line("."),"/*")
call append(line(".")," *".tmphehe."   by xx".strftime("%c"))
call append(line(".")+1," */")endf
map <F2> <Esc>:call Mycomm()<CR><ESC>

哈哈,我弄的注释掉一行的快捷键

[ 本帖最后由 gawk 于 2006-9-12 16:49 编辑 ]


 lowmer 回复于:2006-09-12 17:18:41

引用:原帖由 lovesaka 于 2006-9-12 11:30 发表
to: slay78,lowmer
谢谢两位大侠能把自己的东西拿来共享从两位贴出来的脚本中自己也偷学了不少东西以前有点不怎么会的也给弄明白了,而且找从中找到了更加简洁的方法来实现自己想要的功能,其实是不是自己亲手写 ... 



不是谦虚,真算不上大虾。我只是把7.0的中文help详细地看了一遍,然后又看了“超级长贴”而已。有些选项一眼就看明白的就没加注释。


 Benson_linux 回复于:2006-09-12 17:33:19

我的

set encoding=gb2312
set cindent
set ts=4
set sw=4
set foldcolumn=2
abbreviate // // lyd[
abbreviate //m // lyd[ MARK
abbreviate //c // lyd[ CHANGED
abbreviate //a // lyd[ ADD
abbreviate //d // lyd[ DELETE
abbreviate //D // lyd[ DEBUG
abbreviate //j // lyd[ JSSUPPORT
abbreviate //t // lyd[ TODO
abbreviate printf printf ("####Benson debug:"
abbreviate printk printk ("####Benson debug:"

:map <F2> :s/^/\/\//<CR>

:inoremap( ()<ESC>i
:inoremap) <c-r>=ClosePair(')')<CR>
:inoremap{ {}<ESC>i
:inoremap} <c-r>=ClosePair('}')<CR>
:inoremap[ []<ESC>i
:inoremap] <c-r>=ClosePair(']')<CR>

function ClosePair(char)
if getline('.')[col(',') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf



 sithui 回复于:2006-09-12 17:34:01

弱弱地问一下
自己设置过vim后用什么命令保存到vimrc里面?


 slay78 回复于:2006-09-12 17:36:24

引用:原帖由 sithui 于 2006-9-12 17:34 发表
弱弱地问一下
自己设置过vim后用什么命令保存到vimrc里面? 



直接编辑~/.vimrc文件


 sithui 回复于:2006-09-12 17:38:39

引用:原帖由 slay78 于 2006-9-12 17:36 发表


直接编辑~/.vimrc文件 



要是我在编辑一个源文件的时候更改了一些设置,非得再输入一次到~/.vimrc里面吗?


 lovesaka 回复于:2006-09-12 18:04:55


:inoremap( ()<ESC>i
:inoremap) <c-r>=ClosePair(')')<CR>
:inoremap{ {}<ESC>i
:inoremap} <c-r>=ClosePair('}')<CR>
:inoremap[ []<ESC>i
:inoremap] <c-r>=ClosePair(']')<CR>

function ClosePair(char)
if getline('.')[col(',') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf


这一段补全很实用希望还有更多的实用技巧一一都给贴上哈哈VIM真是太强了:D


 net_robber 回复于:2006-09-13 17:08:48

我还没有好好研究过,呵呵


 newbuding 回复于:2006-09-13 21:51:54

没有认真研究,不过/usr/share/vim/vim70/下面有个例子vimrc_example.vim看起来还不错,改改就非常好用了


 lovesaka 回复于:2006-09-13 23:48:18

一个非常好用的插件能显示当前文件函数,宏,变量
只要把taglist.vim放到VIM插件目录就OK了再到vimrc里加上一个键映射就行了
具体怎么用在taglist.txt里说得很清楚

[ 本帖最后由 lovesaka 于 2006-9-13 23:54 编辑 ]

taglist_41.zip



图一





图二




 dlms 回复于:2006-09-14 09:18:55

你们用的都是什么版本啊!这些都咋用啊!俺一直就用vim当记事本用!


 yangkwch 回复于:2006-09-14 13:10:58

在默认的基础上增加了如下内容:
set number
set hlsearch
set ts=4
set shiftwidth=4
set nobackup
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936


 sailer_sh 回复于:2006-09-14 14:09:17

我的和你的差不多。。。


 lovesaka 回复于:2006-09-15 01:10:43

引用:原帖由 dlms 于 2006-9-14 09:18 发表
你们用的都是什么版本啊!这些都咋用啊!俺一直就用vim当记事本用! 


高手一般都是把VIM当记事本用:mrgreen:
差不多都是7点几吧


 playmud 回复于:2006-09-15 10:23:21

taglist都需要那些配置?
文档看不明白


 lovesaka 回复于:2006-09-15 14:09:51

引用:原帖由 playmud 于 2006-9-15 10:23 发表
taglist都需要那些配置?
文档看不明白 


几乎可以说不用什么配置
我是直接把包解开然后把taglist.vim文件放到VIM安装目录下的plugin目录
再到vimrc里加上一句

nnoremap <silent> <F8> :TlistToggle<CR>

按F8就可以用了


 wolfssss 回复于:2006-09-15 15:59:18

我的,比较简单,个人觉得很好用,注释都加上了

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=utf-8,latin1
endif

set nocompatible        " Use Vim defaults (much better!)
set bs=2                " 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
set number              " show the number of lines
set showcmd             " show the cmd
set whichwrap=b,s,<,>   " can use Backspace Space <Left> <Right> wrap
"set mouse=a             " use mouse in terminal
set helplang=cn         " set the vim helpdoc language
set noignorecase        " set case not sensitivity

vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>          " can paste in the VISUAL mode
filetype plugin indent off

" 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

" 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

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

" Open a file managers
map <F7> <ESC>:vsplit<ENTER>:edit `pwd`<ENTER>i

" Open Tlist
map <F8> <ESC>:Tlist<ENTER>
" Close Tlist width resize
let Tlist_Inc_Winwidth=0

" use Alt+; to add comment,like emacs
autocmd filetype cpp,java map <Esc>; $a<tab><tab>//
autocmd filetype cpp,java imap <Esc>; <End><tab><tab>//
autocmd filetype c map <Esc>; $a<tab><tab>/*   */<Esc>3hi
autocmd filetype c imap <Esc>; <End><tab><tab>/*   */<Left><Left><Left><Left>
autocmd filetype sh map <Esc>; O#



 lovesaka 回复于:2006-09-15 22:48:42


不错如果以后不小心把vimrc文件给毁了到这上面来copy下去还是很便的哈哈:mrgreen:


 lovesaka 回复于:2006-09-16 02:07:53

修改一下加了一个目录浏览vim自带的功能不过在taglist里面用f键就可以看当前目录
多谢谢楼上兄第脚本提示
小提示:在文件管理器下直接ex可以打开文件比如播放音乐,看电子书等等爽得不得了不过还得要你系统上有文件格式相关连的软件才行

[ 本帖最后由 lovesaka 于 2006-9-16 02:30 编辑 ]

taglist.tar



图1





图2




 lovesaka 回复于:2006-09-16 10:48:44

想做一个像vc那样的函数原形显示窗口最好和VIM补全的窗口差不多
却一直下不了手
知道的兄弟给点不妨给点提示


 lovesaka 回复于:2006-09-17 02:49:09

上面所说的要求并非空谈我看到有人在WINDOW下用MFC实现这个功能
所以自己想在LINUX写一个那东西

看来此贴生命周期已了:(


 cnscn123 回复于:2006-10-13 17:30:55

更多请参见: [url=http://blog.chinaunix.net/u/13329/article.php?frmid=21649]http://blog.chinaunix.net/u/13329/article.php?frmid=21649


$cat ~/.vim/plugin/vimrc.vim
"set syntax on
:syntax on

"set no compatible
:set nocompatible

"set backspace
:set backspace=indent,eol,start

"set autoindent
:set ai

"set cautoindent
:set cindent

"set shiftwidth
:set shiftwidth=4

"set soft tab width
:set softtabstop=4

"change tab to spaces
:retab

"set line numbers
:set nu

"set show match (showmatch)
:set sm

"set foldmethod
:set fdm=syntax

"set extend tab
:set et

"set foldmarker
:set foldmarker={{{,}}}

"set match options
:set matchpairs=(:),{:},[:],<:>

:set complete+=k

"set the visualbell
:set visualbell

"set history length
:set history=50

"set the ruler
:set ruler

"set fileencoding=gb2312

"set show command line
:set showcmd

:set incsearch

"set tags file  path
:set tags=~/.vim/_tags

"auto add *, when write /*...*/
:set  formatoptions=tcro

"show tab and spaces
set  listchars=tab:>-,trail:~
set  list
syntax    match Trail " +$"
highlight def link Trail Todo


""""""""""""""""""""""""Maps""""""""""""""""""""""""

if version >= 600

   "find the current word
   map <F3>    /<c-r><c-w><CR>

   "Type List
   map <F2>    :Tlist<CR>

   "remove the space end of a line
   map  ;m     :%s/ *$//g<CR>

   "使用X调用Minmax()函数
   map   X   :call Minmax() <CR>

   "使用T调用MinmaxHeight()函数
   map   T   :call MinmaxHeight() <CR>

   "v%zf
   :map ;c  v%zf

endif



 jing18 回复于:2006-10-16 01:44:25

" 我的 _vimrc 部份設定

" 使用環境:windows XP
" vim 版本:7.0-134

" 編輯 _vimrc
map ,v :e!$vim/_vimrc<CR>

" 開啟個人備忘錄
map ,m :e!D:\117\Cbackup\memo\MEMO.TXT<CR>
" 押日期(map: 命令模式  imap: 搜入模式)
map <F7> a<C-R>=strftime("%c")<CR> 
imap <F7> <C-R>=strftime("%c")<CR> 

" 檔案瀏覽(開啟的目錄為目前編輯檔案所在之目錄)
map ,e :e <C-R>=expand("%:p:h")<CR><CR>    

" set hidden 始可使用以下二個命令(注意!有修改未存檔之陷阱。)
" 切換檔案編輯
map <F8> :bn<CR>
" 查詢編輯中的檔案編號,在:b後輸入編號即可編輯該檔;:bd!輸入編號可強行刪除buffer檔案
map ,r :ls<CR>:b

" set hlsearch, 字串搜尋吻合者高亮度提示,很好!
" 但用完她還亮著不肯離去,礙眼著很!所以,就 ...
map ,h :nohl<CR>

" set wrap 一眼看盡全行,她棒得很!
" 但想要比對上下行時,下行在下邊那一列呢?這時,就 ...
map ,w :set wrap!<CR>

" set nu 看著行號變大,成就感猶然而生。
" 但在成就之後的落寞時,不再需要閑雜人等,此時,就 ...
map ,n :set nu!<CR>

" set cursorline & set cursorcolumn 人近五十視茫眼瞎,浩瀚字海那點游標,找得辛苦!
" 幸好有了這帖清目丸!
map ,s :set cursorline!<CR>:set cursorcolumn!<CR>

" run perl script
map ;r :w<CR>:!perl -w "%:p"<CR>
" debug perl script 
map ;d :w<CR>:!perl -d "%:p"<CR>[color=White]Sample Text[/color]

[ 本帖最后由 jing18 于 2006-10-16 01:47 编辑 ]




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=826707
转载请注明作者名及原文出处



收藏本页到: