码迷,mamicode.com
首页 > 系统相关 > 详细

macvim 配置

时间:2015-05-12 21:03:44      阅读:1229      评论:0      收藏:0      [点我收藏+]

标签:

sublime用着虽然很不错,但是还是有些不习惯的,于是就折腾了下vim。

""===============================
" 更新时间:2015-05-11 17:37
""===============================

" 设置vundle 
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle ‘gmarik/vundle‘


""===============================
""自定义插件vundle设置
" :BundleList - list configured BundleList
" :BundleInstall(!) - install(update) bundles 
" :BundleSearch(!) foo - search(or refresh cache first) for foo "
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
""===============================

"=== Github vim-scripts repos "
" 快速注释、反注释代码
Bundle ‘tComment‘

"=== Github User repos "
""主题
Bundle ‘flazz/vim-colorschemes‘
""以树状方式浏览系统中的文件和目录
Bundle ‘scrooloose/nerdtree‘
"设置子窗口位置"
let g:NERDTreeWinPos = "left"
" 设置NERDTree子窗口宽度
let NERDTreeWinSize=32"
map <C-n> :NERDTreeToggle<CR>

"方便的在字符两边插入各用符号,比如单/双引号,大中小括弧等"
Bundle ‘tpope/vim-surround‘
"打入快速输入括号,引号等,避免出错"
Bundle ‘spf13/vim-autoclose‘

"ctrl + p 文件模糊搜索"
Bundle ‘kien/ctrlp.vim‘
"Bundle ‘ctrlpvim/ctrlp.vim‘
let g:ctrlp_cmd = ‘CtrlP‘
let g:ctrlp_custom_ignore = {
  \ ‘dir‘:  ‘\.git$\|\.hg$\|\.svn$\|\.yardoc\|public\/images\|public\/system\|data\|log\|tmp$‘,
  \ ‘file‘: ‘\.exe$\|\.so$\|\.dat$‘
  \ }
"语法检测"
Bundle ‘scrooloose/syntastic‘
let g:syntastic_check_on_open=1
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_wq = 0
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
"自动补全end关键字"
Bundle ‘tpope/vim-endwise‘
"在快速的在module, class, method中跳跃"
Bundle ‘vim-ruby/vim-ruby‘
"Vim开发Rails不可缺少的一个插件"
Bundle ‘tpope/vim-rails‘
"快速对齐"
Bundle ‘godlygeek/tabular‘
"在文件中快速定位"
Bundle ‘Lokaltog/vim-easymotion‘
"自动补全插件"
Bundle ‘Shougo/neocomplete‘
""代码补全
Bundle ‘Valloric/YouCompleteMe‘
"tab 补全代码
Bundle ‘ervandew/supertab‘
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
let g:SuperTabRetainCompletionType=2

"快速选中结对符"
Bundle ‘gcmt/wildfire.vim‘
map <SPACE> <Plug>(wildfire-fuel)
vmap <S-SPACE> <Plug>(wildfire-water)
"适用于哪些结对符
let g:wildfire_objects = ["i‘", ‘i"‘, "i)", "i]", "i}", "i>", "ip"]


Bundle ‘yegappan/grep‘
Bundle ‘mileszs/ack.vim‘
Bundle ‘dyng/ctrlsf.vim‘
" CtrlSF搜索
" 默认程序为ACK而不是AG
let g:ctrlsf_ackprg = ‘ack‘                                     
"使用 Ctrl + f 打开查找 
nmap     <C-F> <Plug>CtrlSFPrompt 
vmap     <C-F>f <Plug>CtrlSFVwordPath 
vmap     <C-F>F <Plug>CtrlSFVwordExec 
nmap     <C-F>n <Plug>CtrlSFCwordPath 
nmap     <C-F>p <Plug>CtrlSFPwordPath 
nnoremap <C-F>o :CtrlSFOpen<CR> 


""替换
" 定义快捷键的前缀,即 <Leader>
let mapleader=";"

" 替换函数。参数说明:
" confirm:是否替换前逐一确认
" wholeword:是否整词匹配
" replace:被替换字符串
"替换之前要先确定范围 bufdo bufdo! argdo argsdo argsdo!

function! Replace(confirm, wholeword, replace)
    wa
    let flag = ‘‘
    if a:confirm
        let flag .= ‘gec‘
    else
        let flag .= ‘ge‘
    endif
    let search = ‘‘
    if a:wholeword
        let search .= ‘\<‘ . escape(expand(‘<cword>‘), ‘/\.*$^~[‘) . ‘\>‘
    else
        let search .= expand(‘<cword>‘)
    endif
    let replace = escape(a:replace, ‘/\&~‘)
    execute ‘argdo %s/‘ . search . ‘/‘ . replace . ‘/‘ . flag . ‘| update‘
endfunction
" 不确认、非整词
nnoremap <Leader>R :call Replace(0, 0, input(‘Replace ‘.expand(‘<cword>‘).‘ with: ‘))<CR>
" 不确认、整词
nnoremap <Leader>rw :call Replace(0, 1, input(‘Replace ‘.expand(‘<cword>‘).‘ with: ‘))<CR>
" 确认、非整词
nnoremap <Leader>rc :call Replace(1, 0, input(‘Replace ‘.expand(‘<cword>‘).‘ with: ‘))<CR>
" 确认、整词
nnoremap <Leader>rcw :call Replace(1, 1, input(‘Replace ‘.expand(‘<cword>‘).‘ with: ‘))<CR>
nnoremap <Leader>rwc :call Replace(1, 1, input(‘Replace ‘.expand(‘<cword>‘).‘ with: ‘))<CR>



"airline 设置
"git clone git@github.com:Lokaltog/powerline-fonts.git ~/Library/Fonts/powerline-fonts
"./install
"themes: https://github.com/bling/vim-airline/tree/master/autoload/airline/themes
"https://github.com/bling/vim-airline/wiki/Screenshots

Bundle ‘bling/vim-airline‘
"显示状态栏
set laststatus=2
" 使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1
"主题
let g:airline_theme=‘powerlineish‘

let g:airline#extensions#tabline#enabled = 1
" tabline中当前buffer两端的分隔字符
let g:airline#extensions#tabline#left_sep = ‘ ‘
" tabline中未激活buffer两端的分隔字符
let g:airline#extensions#tabline#left_alt_sep = ‘|‘
" tabline中buffer显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1

" 映射切换buffer的键位,你只能通过 :ls 来查看buffer.
"然后通过 :bn (buffer next)和 :bp (buffer previous),或者 :b num (打开编号为num的buffer)这样的命令来切换不同文件
nnoremap [b :bp<CR>
nnoremap ]b :bn<CR>


Bundle ‘pbrisbin/vim-mkdir‘


Bundle ‘amirh/HTML-AutoCloseTag‘
Bundle ‘hail2u/vim-css3-syntax‘
Bundle ‘slim-template/vim-slim‘
Bundle ‘tpope/vim-haml‘
Bundle ‘MarcWeber/vim-addon-mw-utils‘
if executable(‘ctags‘)
  Bundle ‘majutsushi/tagbar‘
endif
"tagbar是一个taglist的替代品
nmap tl :TagbarToggle<CR>


"Github non repos "
Bundle ‘git@github.com:vim-scripts/taglist.vim.git‘
Bundle ‘git@github.com:vim-scripts/buftabs.git‘

"================================



let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1



" 自适应不同语言的智能缩进"
filetype plugin indent on
"设置语法高亮"
syntax enable
syntax on
"设置编码"
set encoding=utf-8
set fileencodings=utf-8,gbk,ucs-bom,gb18030,gb2312,cp936
"显示行号"
set number
"设置默认窗口大小"
set lines=44 columns=150
"调色版"
colorscheme desertEx
"在Insert模式下,设置Backspace键如何删除光标前边的字符。这里三个值分别表示空白字符,分行符和插入模式之前的字符"
set backspace=indent,eol,start
"保存700条命令历史记录"
set history=700
"总是在窗口右下角显示光标的位置"
set ruler
"忽略大小写"
set ignorecase
"启动搜索高亮."
set hlsearch
"在查找时输入字符过程中就高亮显示匹配点。然后回车跳到该匹配点。"
set incsearch
" 总是显示状态栏"
set laststatus=2
" 高亮显示当前行"
set cursorline
" 基于缩进或语法进行代码折叠
set foldmethod=indent
" 启动 vim 时关闭折叠代码
set nofoldenable
" 设置 gvim 显示字体
"set guifont=Monaco:h13
set guifont=Literation_Mono_Powerline:h16
"vim 自身命令行模式智能补全
set wildmenu

" 禁止显示滚动条
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R

" 禁止显示菜单和工具条
set guioptions-=m
set guioptions-=T


" 将制表符扩展为空格
set expandtab
" 设置编辑时制表符占用空格数
set tabstop=4
" 设置格式化时制表符占用空格数
set shiftwidth=4
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=4





"Omnicoplete的配置"
" OmniComplete {
    if has("autocmd") && exists("+omnifunc")
        autocmd Filetype *
            \if &omnifunc == "" |
            \setlocal omnifunc=syntaxcomplete#Complete |
            \endif
    endif

    " Some convenient mappings
    inoremap <expr> <Esc>      pumvisible() ? "\<C-e>" : "\<Esc>"
    inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>"
    inoremap <expr> <Down>     pumvisible() ? "\<C-n>" : "\<Down>"
    inoremap <expr> <Up>       pumvisible() ? "\<C-p>" : "\<Up>"
    inoremap <expr> <C-d>      pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
    inoremap <expr> <C-u>      pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"

    " Automatically open and close the popup menu / preview window
    au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
    set completeopt=menu,preview,longest
" }

" Ctags {
    ""set tags=./tags;/,~/.vimtags

    " Make tags placed in .git/tags file available in all levels of a repository
    ""let gitroot = substitute(system(‘git rev-parse --show-toplevel‘), ‘[\n\r]‘, ‘‘, ‘g‘)
    ""if gitroot != ‘‘
    ""    let &tags = &tags . ‘,‘ . gitroot . ‘/.git/tags‘
    ""endif
" }

" AutoCloseTag {
    " Make it so AutoCloseTag works for xml and xhtml files as well
""    au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
""    nmap <Leader>ac <Plug>ToggleAutoCloseMappings
" }



" neocomplete的配置 
" neocomplete {
"Note: This option must set it in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = ‘\*ku\*‘
let g:neocomplete#enable_fuzzy_completion = 1
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#max_list = 5
let g:neocomplete#enable_auto_delimiter = 1
let g:neocomplete#force_overwrite_completefunc = 1
let g:neocomplete#auto_completion_start_length = 2

" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
    \ ‘default‘ : ‘‘,
    \ ‘vimshell‘ : $HOME.‘/.vimshell_hist‘,
    \ ‘scheme‘ : $HOME.‘/.gosh_completions‘
        \ }

" Define keyword.
if !exists(‘g:neocomplete#keyword_patterns‘)
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns[‘default‘] = ‘\h\w*‘

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplete#undo_completion()
inoremap <expr><C-l>     neocomplete#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  "return neocomplete#close_popup() . "\<CR>"
  " For no inserting <CR> key.
  return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y>  neocomplete#close_popup()
inoremap <expr><C-e>  neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"

" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left>  neocomplete#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
"inoremap <expr><Up>    neocomplete#close_popup() . "\<Up>"
"inoremap <expr><Down>  neocomplete#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplete#enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplete#enable_insert_char_pre = 1

" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1

" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete

" Enable heavy omni completion.
if !exists(‘g:neocomplete#sources#omni#input_patterns‘)
  let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = ‘[^. \t]->\h\w*\|\h\w*::‘
"let g:neocomplete#sources#omni#input_patterns.c = ‘[^.[:digit:] *\t]\%(\.\|->\)‘
"let g:neocomplete#sources#omni#input_patterns.cpp = ‘[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::‘
let g:neocomplete#sources#omni#input_patterns.php = ‘[^. \t]->\h\w*\|\h\w*::‘
let g:neocomplete#sources#omni#input_patterns.perl = ‘\h\w*->\h\w*\|\h\w*::‘
let g:neocomplete#sources#omni#input_patterns.c = ‘[^.[:digit:] *\t]\%(\.\|->\)‘
let g:neocomplete#sources#omni#input_patterns.cpp = ‘[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::‘
let g:neocomplete#sources#omni#input_patterns.ruby = ‘[^. *\t]\.\h\w*\|\h\w*::‘
let g:neocomplete#sources#omni#input_patterns.go = ‘\h\w*\.\?‘

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = ‘\h\w*->\h\w*\|\h\w*::‘
" }
"




macvim 配置

标签:

原文地址:http://blog.csdn.net/iitvip/article/details/45674347

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!