美文网首页
我的Vim配置

我的Vim配置

作者: sylcrq | 来源:发表于2016-07-09 19:06 被阅读488次

    本文的Vim配置是在 spf13-vim 的基础上进行自定义修改
    所需即所获:像 IDE 一样使用 vim
    使用Vundle管理配置Vim基本插件

    目前遇到的问题:
    Vim中同时打开NERDTree(左边)和Tagbar时(右边),有一个会无法正常显示

    使用 spf13-vim

    https://github.com/spf13/spf13-vim

    • Mac OS上安装:
      //Requires Git 1.7+ and Vim 7.3+
      curl https://j.mp/spf13-vim3 -L > spf13-vim.sh && sh spf13-vim.sh
      
    • 更新版本:
      curl https://j.mp/spf13-vim3 -L -o - | sh
      

    或者

    cd $HOME/to/spf13-vim/
    git pull
    vim +BundleInstall! +BundleClean +q
    
    • 自定义的Vim配置修改放在 ~/.vimrc.local~/.gvimrc.local 文件中

    • 需要在spf13-vim.vimrc 之前加载的自定义配置放在 ~/.vimrc.before.local 文件中

    • Spf13-vim 使用 let mapleader = ","<Leader> 键映射为 ,

    Vundle(Vim插件管理器)

    Vundle = Vim bundle
    https://github.com/VundleVim/Vundle.vim

    • 添加的新插件放在 ~/.vimrc.bundles.local 文件中

      echo Bundle \'spf13/vim-colors\' >> ~/.vimrc.bundles.local
      //安装
      vim +BundleInstall! +BundleClean +q
      
    • 删除已安装的插件放在 ~/.vimrc.local 文件中

      echo UnBundle \'AutoClose\' >> ~/.vimrc.bundles.local
      echo UnBundle \'scrooloose/syntastic\' >> ~/.vimrc.bundles.local
      

      然后在Vim中执行:BundleClean!

    Vim插件配置

    1. NERDTree(文件目录导航)

    https://github.com/scrooloose/nerdtree

    • 打开/关闭的快捷键:F2
    " <==== NERDTree Config ====>
    " open a NERDTree automatically when vim starts up
    "autocmd vimenter * NERDTree
    " open NERDTree on startup, and have my cursor start in the other window
    autocmd vimenter * wincmd p
    " map a specific key or shortcut to open NERDTree
    map <F2> :NERDTreeToggle<CR>
    " close vim if the only window left open is a NERDTree
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
    " 设置NERDTree子窗口宽度
    let NERDTreeWinSize=32
    " 设置NERDTree子窗口位置
    "let NERDTreeWinPos="right"
    " 不显示隐藏文件
    let NERDTreeShowHidden=0
    " NERDTree子窗口中不显示冗余帮助信息
    let NERDTreeMinimalUI=1
    

    2. NERDCommenter(快速注释)

    https://github.com/scrooloose/nerdcommenter

    3. Tagbar(当前文件tag导航)

    https://github.com/majutsushi/tagbar

    • 打开/关闭的快捷键:F8
    " <==== Tagbar Config ====>
    autocmd VimEnter * nested :TagbarOpen
    nmap <F8> :TagbarToggle<CR>
    " 设置标签子窗口的宽度
    let tagbar_width=32
    " 设置tagbar子窗口的位置出现在主编辑区的左边
    "let tagbar_left=1
    " tagbar子窗口中不显示冗余帮助信息
    let g:tagbar_compact=1
    

    相关文章

      网友评论

          本文标题:我的Vim配置

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