美文网首页
(G)VIM的安装与配置

(G)VIM的安装与配置

作者: J书越来越垃圾了 | 来源:发表于2017-04-23 17:37 被阅读58次

    首先都是通过vundle管理插件的
    后附vimrc

    window

    下载安装gvim

    在vimrc中添加如下

    set rtp+=$VIM/vimfiles/bundle/vundle/  
    call vundle#rc('$VIM/vimfiles/bundle/')  
    Bundle 'gmarik/vundle'
    

    如果要实现函数的跳转,记得去下载ctags 并将 ctags.exe 一个文件 放到vim74目录下即可
    https://sourceforge.net/projects/ctags/files/ctags/5.8/ctags58.zip/download?nowrap
    如果要实现透明请下载vimtweak.dll*

    Linux

    git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

    set rtp+=~/.vim/bundle/vundle/
    call vundle#rc()
    Bundle 'gmarik/vundle'
    

    vimrc配置

    set nocompatible
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/mswin.vim
    behave mswin
    "最大化
    autocmd GUIEnter * simalt ~x
    "窗口化
    "winpos 535 22
    "set lines=35 columns=108 
    "colo peachpuff 
    "set autoindent 
    
    
    set nu!            "设置行号
    set background=dark
    colorscheme molokai     "设置配色方案
    syntax on         "文件类型侦测
    syntax enable        "语法高丽
    set nobackup        "不生成备份文件
    set showmatch        "设置匹配模式
    set smartindent        "设置智能对齐
    set ai!            "设置自动缩进
    set fileencodings=utf-8,gbk
    set ambiwidth=double    "设置中文支持
    set guifont=consolas:h11 "设置字体及大小
    "set guifont=Ubuntu\ Mono:h12
    set mouse=a        "启用鼠标
    "按y键复制,然后点击要粘贴的地方使用鼠标中键粘贴
    >  'mouse' 选项的字符决定 Vim 在什么场合下会使用鼠标:
                    n       普通模式
                    v       可视模式
                    i       插入模式
                    c       命令行模式
                    h       在帮助文件里,以上所有的模式
                    a       以上所有的模式
                    r       跳过 |hit-enter| 提示
                    A       在可视模式下自动选择
    
    set softtabstop=4   "一次tab前进4个字符
    set expandtab   "空格代替tab
    set formatoptions+=mM
    set hidden      "允许为保存时切换到缓冲区
    set history=1024 "历史记录
    set helplang=cn "中文帮助\
    set wrap    "自动换行
    set linebreak   "整词换行
    "set guioptions-=T   "隐藏工具栏
    set go=  "界面无边框
    " 开启折叠
    set foldmethod=indent
    set foldlevel=99
    nnoremap <space> za  "Normal下 空格即可对代码进行折叠
    
    autocmd FileType php setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
    autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
    autocmd FileType php setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
    autocmd FileType coffee,javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
    autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
    autocmd FileType html,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0
    autocmd FileType sass,scss,css setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=12
    
    "补全
    filetype plugin on                                             
    autocmd FileType php set omnifunc=phpcomplete#CompletePHP
    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 c setlocal omnifunc=ccomplete#Complete
    
    "vundle插件管理
    set rtp+=$VIM/vimfiles/bundle/vundle/  
    call vundle#rc('$VIM/vimfiles/bundle/')  
    Bundle 'gmarik/vundle'
    
    "ctags set 
    let Tlist_Show_Menu = 1
    set tags=tags;
    set autochdir
    
    
    
    "tagbar类似taglist 对面向对象更友好
    Bundle 'majutsushi/tagbar'
    nmap <F8> :TagbarToggle<CR>
    
    "快速搜索
    "Bundle 'kien/ctrlp.vim'
    
    "对齐线 "色块
    Bundle 'nathanaelkane/vim-indent-guides'
    "let g:indent_guides_enable_on_vim_startup = 1
    let g:indent_guides_auto_colors = 0
    let g:indent_guides_guide_size = 1 
    autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd  guibg=#333333 ctermbg=3
    autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#444444 ctermbg=4
    map <F3> :IndentGuidesToggle<CR>
    
    "文件夹列表
    Bundle 'scrooloose/nerdtree'
    let NERDTreeWinPos='left'
    let NERDTreeWinSize=30
    map <F2> :NERDTreeToggle<CR>
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif
    
    "vim 下方彩色状态栏
    Bundle 'bling/vim-airline'
    set laststatus=2
    
    
    
    
    "php
    Bundle 'php.vim'
    
    "透明 针对window 需要下vimtweak.dll
    "Alpha Window
    nmap <M-r> :call libcallnr("vimtweak.dll","SetAlpha",215)<cr>
    nmap <M-e> :call libcallnr("vimtweak.dll","SetAlpha",255)<cr>
    "Maximized Window
    map <leader>mw :call libcallnr("vimtweak.dll","EnableMaximize",1)<cr>
    map <leader>mW :call libcallnr("vimtweak.dll","EnableMaximize",0)<cr>
    "TopMost Window
    map <leader>et :call libcallnr("vimtweak.dll","EnableTopMost",1)<cr>
    map <leader>eT :call libcallnr("vimtweak.dll","EnableTopMost",0)<cr>
    
    
    nnoremap ; :
    :command W w
    :command WQ wq
    :command Wq wq
    :command Q q
    :command Qa qa
    :command QA q
    

    相关文章

      网友评论

          本文标题:(G)VIM的安装与配置

          本文链接:https://www.haomeiwen.com/subject/ideyzttx.html