一、Spacevim简介

SpaceVim 是一个社区驱动的模块化的 Vim IDE,以模块的方式组织管理插件以及相关配置, 为不同的语言开发量身定制了相关的开发模块,该模块提供代码自动补全, 语法检查、格式化、调试、REPL 等特性。用户仅需载入相关语言的模块即可得到一个开箱即用的 Vim IDE。
官方网站:https://spacevim.org
GitHub项目主页:https://github.com/SpaceVim/SpaceVim

Spacevim使用教程 - 图1

二、安装

  • Linux或Mac
    Linux或Mac下的安装非常简单,只需要执行以下命令即可:

    1. curl -sLf https://spacevim.org/install.sh | bash

  • 想要获取更多的自定义的安装方式,请参考:

    curl -sLf https://spacevim.org/install.sh | bash -s -- -h
    
  • Windows
    Windows下vim用户只需要将本仓库克隆成用户 HOME 目录下的vimfiles即可,打开CMD默认的目录默认即为 HOME 目录,只需要执行如下命令即可:

    git clone https://github.com/SpaceVim/SpaceVim.git vimfiles
    

三、使用

  • Unite 为主的工作平台
    Unite 的快捷键前缀是f,可以通过 g:spacevim_unite_leader来设定,快捷键无需记忆,SpaceVim 有很好的快捷键辅助机制。
    如下是 Unite 的快捷键键图:
    Spacevim使用教程 - 图2
    自动补全:SpaceVim 采用最快补全引擎 deoplete, 该引擎不同与 YouCompleteMe 的主要一点是支持多源补全,而不单单是语义补全。 而且补全来源拓展非常方便。
  • 用户配置
    SpaceVim将从~/.SpaceVim.d/init.vim和当前目录的./SpaceVim.d/init.vim载入配置,并且更新 rtp,用户可以在 ~/.SpaceVim.d/.SpaceVim.d/这两个文件夹下编辑自己的脚本,和SpaceVim的配置文件。
    示例:

    " Here are some basic customizations,
    " please refer to the ~/.SpaceVim.d/init.vim
    " file for all possible options:
    let g:spacevim_default_indent = 3
    let g:spacevim_max_column     = 80
    " Change the default directory where all miscellaneous persistent files go.
    " By default it is ~/.cache/vimfiles.
    let g:spacevim_plugin_bundle_dir = '~/.cache/vimfiles'
    " set SpaceVim colorscheme
    let g:spacevim_colorscheme = 'jellybeans'
    " Set plugin manager, you want to use, default is dein.vim
    let g:spacevim_plugin_manager = 'dein'  " neobundle or dein or vim-plug
    " use space as ``
    let mapleader = "\"
    " Set windows shortcut leader [Window], default is `s`
    let g:spacevim_windows_leader = 's'
    " Set unite work flow shortcut leader [Unite], default is `f`
    let g:spacevim_unite_leader = 'f'
    " By default, language specific plugins are not loaded. This can be changed
    " with the following, then the plugins for go development will be loaded.
    call SpaceVim#layers#load('lang#go')
    " loaded ui layer
    call SpaceVim#layers#load('ui')
    " If there is a particular plugin you don't like, you can define this
    " variable to disable them entirely:
    let g:spacevim_disabled_plugins=[
      \ ['junegunn/fzf.vim'],
      \ ]
    " If you want to add some custom plugins, use these options:
    let g:spacevim_custom_plugins = [
      \ ['plasticboy/vim-markdown', {'on_ft' : 'markdown'}],
      \ ['wsdjeg/GitHub.vim'],
      \ ]
    " set the guifont
    let g:spacevim_guifont = 'DejaVu\ Sans\ Mono\ for\ Powerline\ 11'
    
  • SpaceVim选项
    Spacevim使用教程 - 图3