| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3551 人关注过本帖
标题:傻瓜式一键配置 gVim 编辑器
只看楼主 加入收藏
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
结帖率:94.72%
收藏
已结贴  问题点数:20 回复次数:10 
傻瓜式一键配置 gVim 编辑器
...

[ 本帖最后由 BlueGuy 于 2010-12-10 04:04 编辑 ]
搜索更多相关主题的帖子: 傻瓜 gVim 编辑器 
2010-05-16 07:45
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
收藏
得分:0 
这个是附件, 你可以不用管的

source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@
" Last change: 2008 Jul 02
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"       for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"     for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
    finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.

" allow backspacing over everything in insert mode

if has("vms")
    set nobackup  " do not keep a backup file, use versions instead
else
    set backup  " keep a backup file
endif

:let mapleader = ","
:let loaded_winmanager = 1

:let Tlist_Show_One_File=1
:let Tlist_Auto_Open=1
:let Tlist_Exit_OnlyWindow=1
:let Tlist_Use_Right_window=1

:let showmarks_enable=1
:let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
:let showmarks_ignore_type = "hqm"
:let showmarks_hlline_lower = 1
:let showmarks_hlline_upper = 1

:set backspace=indent,eol,start
:set nocompatible
:set guioptions+=b
:set noswapfile
:set matchpairs=(:),{:},[:],<:>
:set completeopt=longest,menu
:set comments=s1:/*,mb:*,ex:*/
:set formatoptions=qro
:set cmdheight=3
:set fo=croq
:set nu
:set nocp
:set makeprg=nmake.exe
:set showmatch
:set matchtime=10
:set nowrap
:set sidescroll=10
:set listchars=tab:>-,trail:-
:set softtabstop=4
:set cindent shiftwidth=4
:set history=50  " keep 50 lines of command line history
:set ruler  " show the cursor position all the time
:set showcmd  " display incomplete commands
:set incsearch  " do incremental searching
:set formatlistpat=1
:set path+=c:\SinaProject\Demo\Inc,c:\SinaProject\Demo\sdk

:map <F12> <Esc>:cs add C:\SinaProject\cscope.out<CR>
:map <F11> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q<CR>

:imap () ()<Left>
:imap [] []<Left>
:imap {} {}<Left>
:imap "" ""<Left>
:imap <> <><Left>

:vmap <silent> <unique> <Leader>cr <Plug>CRV_CRefVimVisual
:nmap <silent> <unique> <Leader>cr: C:\gVim\vimfiles\plugin\crefvim.vim
:map <silent> <unique> <Leader>cw <Plug>CRV_CRefVimAsk
:map <silent> <unique> <Leader>cc <Plug>CRV_CRefVimInvoke

:inoremap <C-U> <C-G>u<C-U>

:autocmd FileType c,cpp  setl fdm=syntax | setl fen
:colorscheme evening
:filetype plugin on
:filetype indent on
:highlight Comment ctermfg=green guifg=green

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

" Don't use Ex mode, use Q for formatting


" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.


" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
    set mouse=a
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

" Only do this part when compiled with support for autocommands.
if has("autocmd")

    " Enable file type detection.
    " Use the default filetype settings, so that mail gets 'tw' set to 72,
    " 'cindent' is on in C files, etc.
    " Also load indent files, to automatically do language-dependent indenting.
    filetype plugin indent on

    " Put these in an autocmd group, so that we can delete them easily.
    augroup vimrcEx
 au!
 " For all text files set 'textwidth' to 78 characters.
 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).
 " Also don't do it when the mark is in the first line, that is the default
 " position when opening a file.
 autocmd BufReadPost *
      \ if line("'\"") > 1 && line("'-:special:1:-") <= line("$") |
      \   exe "normal! g`-:special:1:-" |
      \ 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.
" Only define it when not defined already.
if !exists(":DiffOrig")
    command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
  \ | wincmd p | diffthis
endif

"功能说明:加入或删除注释//
"映射和绑定
nmap <F2> <Esc>:Setcomment<CR>
imap <F2> <Esc>:Setcomment<CR>
vmap <F2> <Esc>:SetcommentV<CR>

command! -nargs=0 Setcomment call s:SET_COMMENT()
command! -nargs=0 SetcommentV call s:SET_COMMENTV()
"非视图模式下所调用的函数
function! s:SET_COMMENT()
    let lindex=line(".")
    let str=getline(lindex)
    "查看当前是否为注释行
    let CommentMsg=s:IsComment(str)
    call s:SET_COMMENTV_LINE(lindex,CommentMsg[1],CommentMsg[0])
endfunction

"视图模式下所调用的函数
function! s:SET_COMMENTV()
    let lbeginindex=line("'<") "得到视图中的第一行的行数
    let lendindex=line("'>") "得到视图中的最后一行的行数
    let str=getline(lbeginindex)
    "查看当前是否为注释行
    let CommentMsg=s:IsComment(str)
    "为各行设置
    let i=lbeginindex
    while i<=lendindex
 call s:SET_COMMENTV_LINE(i,CommentMsg[1],CommentMsg[0])
 let i=i+1
    endwhile
endfunction

"设置注释
"index:在第几行
"pos:在第几列
"comment_flag: 0:添加注释符 1:删除注释符
function! s:SET_COMMENTV_LINE( index,pos, comment_flag )
    let poscur = [0, 0,0, 0]
    let poscur[1]=a:index
    let poscur[2]=a:pos+1
    call setpos(".",poscur) "设置光标的位置

    if a:comment_flag==0
 "插入//
 exec "normal! i//"
    else
 "删除//
 exec "normal! xx"
    endif
endfunction


"*******************************************************


"查看当前是否为注释行并返回相关信息
"str:一行代码
function! s:IsComment(str)
    let ret= [0, 0] "第一项为是否为注释行(0,1),第二项为要处理的列,
    let i=0
    let strlen=len(a:str)
    while i<strlen
 "空格和tab允许为"//"的前缀
 if !(a:str[i]==' ' || a:str[i] == ' ' )
     let ret[1]=i
     if a:str[i]=='/' && a:str[i+1]=='/'
  let ret[0]=1
     else
  let ret[0]=0
     endif
     return ret
 endif
 let i=i+1
    endwhile
    return [0,0] "空串处理
endfunction

"******************************************************
"Locate and return character "above" current cursor position...
function! LookUpwards()
   "Locate current column and preceding line from which to copy...
   let column_num      = virtcol('.')
   let target_pattern  = '\%' . column_num . 'v.'
   let target_line_num = search(target_pattern . '*\S', 'bnW')

   "If target line found, return vertically copied character...
   if !target_line_num
      return ""
   else
      return matchstr(getline(target_line_num), target_pattern)
   endif
endfunction

"Reimplement CTRL-Y within insert mode...
imap <silent>  <C-Y>  <C-R><C-R>=LookUpwards()<CR>

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


[ 本帖最后由 BlueGuy 于 2010-5-27 18:55 编辑 ]

我就是真命天子,顺我者生,逆我者死!
2010-05-16 08:28
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册

我就是真命天子,顺我者生,逆我者死!
2010-05-16 08:29
冥卫
Rank: 8Rank: 8
来 自:深山老林
等 级:蝙蝠侠
帖 子:280
专家分:772
注 册:2010-4-20
收藏
得分:4 
LZ强悍
2010-05-16 08:47
tfxanxing
Rank: 3Rank: 3
等 级:论坛游侠
威 望:2
帖 子:82
专家分:165
注 册:2010-5-7
收藏
得分:4 
  han
2010-05-16 19:45
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:4 
mswin.vim 不推荐,会隐藏很多vim特色功能。

专心编程………
飞燕算法初级群:3996098
我的Blog
2010-05-16 21:07
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
收藏
得分:0 
踏破铁鞋无觅处,得来全不费功夫
无意中解决了困挠很久的vim从另一行拷贝的ctrl+Y命令问题,/

[ 本帖最后由 BlueGuy 于 2010-5-22 10:56 编辑 ]

我就是真命天子,顺我者生,逆我者死!
2010-05-17 18:15
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
收藏
得分:0 
下载的朋友记得更新一下 _vimrc, 添加了几个好用的功能,

我就是真命天子,顺我者生,逆我者死!
2010-05-22 11:03
yanglei1314
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-5-27
收藏
得分:0 
有点深            不是很懂     
2010-05-27 17:50
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
收藏
得分:0 
这个要顶

天之道,利而不害。圣人之道,为而不争。信言不美,美言不信。善者不辩,辩者不善。知者不博,博者不知。
2010-07-14 23:02
快速回复:傻瓜式一键配置 gVim 编辑器
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026635 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved