开发工具 让你的 Vim 更加高效和强大 - SpaceVim

wsdjeg · 2016年12月28日 · 最后由 tannusinghal2 回复于 2024年10月14日 · 15977 次阅读

SpaceVim 中文手册

welcome-page

项 目 主 页: https://spacevim.org

Github 地址 : https://github.com/SpaceVim/SpaceVim

SpaceVim 是一个社区驱动的模块化 vim/neovim 配置集合,其中包含了多种功能模块,并且针对 neovim 做了功能优化。spacevim 有多种功能模块可供用户选择,针对不同语言选择特定的模块,就可以配置出一个适合特定语言开发的环境。

使用过程中遇到问题或者有什么功能需求可以在 github 提交 issue,这将更容易被关注和修复。我们也欢迎喜欢 vim/neovim 的用户加入我们的 QQ 群,一起讨论 vim 相关的技巧,点击加入 Vim/SpaceVim 用户群

以下是近几周的开发汇总:

Throughput Graph

捐助 SpaceVim

微信 支付宝
weixin zhifubao

安装

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

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

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

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

SpaceVim 是一种模块化配置,可以运行在 vim 或者 neovim 上,关于 vim 以及 neovim 的安装,请参考以下链接:

安装 neovim

从源码编译 vim

windows 系统下的安装步骤:

Windows 下 vim 用户只需要将本仓库克隆成用户 HOME 目录下的 vimfiles 即可,打开 CMD 默认的目录默认即为 HOME 目录,只需要执行如下命令即可:

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

Windows 下 neovim 用户 需要将本仓库克隆成用户 HOME 目录下的 AppData\Local\nvim,想要获取跟多关于 neovim 安装相关的知识,可以访问 neovim 的 wiki,wiki 写的非常详细。打开 CMD 初始目录默认一般即为 HOME 目录,只需要执行如下命令即可:

git clone https://github.com/SpaceVim/SpaceVim.git AppData\Local\nvim

字体

SpaceVim 默认启用了 Powerline 字体,默认的的字体文件是:DejaVu Sans Mono, Windows 用户直接下载下来右键安装即可。

vimproc.dll

Windows 下用户如果不方便编译,可以在 qq 群文件里面下载相应的 dll 文件放到 vimproc 的 lib 目录,默认是 ~/.cache/vimfiles/repos/github.com/Shougo/vimproc.vim/lib/

更新

可以通过 :SPUpdate 命令来更新 spacevim 以及包含的插件,如果需要更新指定的插件,如:startuptime.vim,只需要执行 :SPUpdate startuptime.vim,也可以通过 :SPUpdate SpaceVim 来更新 SpaceVim.

文档

核心思想

四大核心思想:记忆辅助,可视化交互,一致性,社区驱动。

如果违背了以上四大核心思想,我们将会尽力修复。

记忆辅助

所有快捷键,根据其功能的不同分为不同的组,以相应的按键作为前缀,例如 b 为 buffer 相关快捷键前缀,p 为 project 相关快捷键前缀, s 为 search 相关快捷键前缀,h 为 help 相关快捷键前缀。

可视化交互

创新的实时快捷键辅助系统,以及查询系统,方便快捷查询到可用的模块、插件以及其他更多信息。

一致性

相似的功能使用同样的快捷键,这在 SpaceVim 中随处可见。这得益于明确的约定。其他模块的文档都以此为基础。

社区驱动

社区驱动,保证了 bug 修复的速度,以及新特性更新的速度。

显著特性

  • 详细的文档: 在 SpaceVim 通过 :h SpaceVim 来访问 SpaceVim 帮助文档。
  • 优雅简洁的界面: 你将会喜欢这样的优雅而实用的界面。
  • 确保手指不离开主键盘区域: 使用 Space 作为前缀键,合理组织快捷键,确保手指不离开主键盘区域。
  • 快捷键辅助系统: SpaceVim 所有快捷键无需记忆,当输入出现停顿,会实时提示可用按键及其功能。
  • 更快的启动时间: 得益于 dein.vim, SpaceVim 中 90% 的插件都是按需载入的。
  • 更少的肌肉损伤: 频繁使用空格键,取代 ctrlshift 等按键,大大减少了手指的肌肉损伤。
  • 更易扩展: 依照一些约定,很容易将现有的插件集成到 SpaceVim 中来。
  • 完美支持 Neovim: 依赖于 Neovim 的 romote 插件以及 异步 API,SpaceVim 运行在 Neovim 下将有更加完美的体验。

快捷键导航

SpaceVim 所有的快捷键都不需要去记忆,有强大的快捷键导航系统来提示每一个按键的具体功能,比如 Normal 模式下按下空格键,将出现如下提示:

mapping-guide

这一导航提示将所有以空格为前缀的快捷键分组展示,比如 b 是所以 buffer 相关的快捷键, p 是所有工程管理相关的快捷键。在导航模式下按下 <C-h> 你将在状态栏上看见相应的帮助信息,按键介绍如下:

按键 描述
u 撤销前一按键
n 导航系统下一页
p 导航系统前一页

运行截图

欢迎页面

welcome-page

工作界面

work-flow

Neovim 运行在 iTerm2 上,采用 SpaceVim,配色为:base16-solarized-dark

展示了一个通用的前端开发界面,用于开发:JavaScript (jQuery), SASS, and PHP buffers.

图中包含了一个 Neovim 的终端,一个语法树窗口,一个文件树窗口以及一个 TernJS 定义窗口

想要查阅更多截图,清阅读 issue #415

谁将从 SpaceVim 中获益?

  • 初级 Vim 用户。
  • 追求优雅界面的 Vim 用户
  • 追求更少肌肉损伤的 Vim 用户
  • 想要学习一种不一样的编辑文件方式的 Vim 用户
  • 追求简单但是可高度配置系统的 Vim 用户

更新和回滚

SpaceVim 自身更新

可通过很多种方式来更新 SpaceVim 的核心文件。建议在更新 SpaceVim 之前,更新一下所有的插件。具体内容如下:

自动更新

注意:默认,这一特性是禁用的,因为自动更新将会增加 SpaceVim 的启动时间,影响用户体验。如果你需要这一特性,可以将如下加入到用户配置文件中:let g:spacevim_automatic_update = 1

启用这一特性后,SpaceVim 将会在每次启动时候检测是否有新版本。更新后需重启 SpaceVim。

通过插件管理器更新

使用 :SPUpdate SpaceVim 这一命令,将会打开 SpaceVim 的插件管理器,更新 SpaceVim,具体进度会在插件管理器 buffer 中展示。

通过 git 进行更新

可通过在 SpaceVim 目录中手动执行 git pull,SpaceVim 在 windows 下默认目录为 ~/vimfilers, 但在 Linux 下则可使用如下命令: git -C ~/.SpaceVim pull.

更新插件

使用 :SPUpdate 这一命令将会更新所有插件,包括 SpaceVim 自身。当然这一命令也支持参数,参数为插件名称,可同时添加多个插件名称作为参数,同时可以使用 Tab 键来补全插件名称。

配置模块

这里仅仅是大致罗列了下常用的模块,若要了解关于配置模块更加详细的信息,可阅读 SpaceVim's layers page,(强烈建议阅读!)

用户配置

用户配置保存在 ~/.SpaceVim.d/ 文件夹。

自动生成用户配置

初次启动 SpaceVim 时,他将提供选择目录,用户需要选择合适自己的配置模板。此时,SpaceVim 将自动在 HOME 目录生成 ~/.SpaceVim.d/init.vim

用户配置目录

~/.SpaceVim.d/ 将被加入 Vim 的运行时路径 &runtimepath。详情清阅读 :h rtp.

当然,你也可以通过 SPACEVIMDIR 这一环境变量,执定用户配置目录。当然也可以通过软连接连改变目录位置,以便配置备份。

SpaceVim 同时还支持项目本地配置,配置出世文件为,当前目录下的 .SpaceVim.d/init.vim 文件。同时当前目录下的 .SpaceVim.d/ 也将被加入到 Vim 运行时路径。

这是一个用户配置文件示例:

" 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 `<Leader>`
let mapleader = "\<space>"

" 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 选项可以查阅 :h SpaceVim.

概念

临时快捷键

SpaceVim 根据需要定义了很多临时快捷键,这将避免需要重复某些操作时,过多按下 SPC 前置键。当临时快捷键启用时,会在窗口下方打开一个快捷键介绍窗口,提示每一临时快捷键的功能。此外一些格外的辅助信息也将会体现出来。

文本移动临时快捷键:

Move Text Transient State

优雅的界面

SpaceVim 集成了多种使用 UI 插件,如常用的文件树、语法树等插件,配色主题默认采用的是 gruvbox。

UI

主题

SpaceVim 默认的颜色主题采用的是 gruvbox。这一主题有深色和浅色两种。关于这一主题一些详细的配置可以阅读 :h gruvbox.

如果需要修改 SpaceVim 的主题,可以在 ~/.SpaceVim.d/init.vim 中修改 g:g:spacevim_colorscheme。例如,使用 vim-one with dark colorscheme

let g:spacevim_colorscheme = 'one'
let g:spacevim_colorscheme_bg = 'dark'
快捷键 描述
SPC T n 切换至下一个随机主题
SPC T s 通过 Unite 选择主题

可以在主题模块中查看 SpaceVim 支持的所有主题。

注意:

SpaceVim 在终端下默认使用了真色,因此使用之前需要确认下你的终端是否支持真色,可以阅读 Colours in terminal 了解根多关于真色的信息。

字体

在 SpaceVim 中默认的字体是 DejaVu Sans Mono for Powerline. 如果你也喜欢这一字体,建议将这一字体安装到系统中。如果需要修改 SpaceVim 的字体,可以在用户配置文件中修改 g:spacevim_guifont,默认值为:

let g:spacevim_guifont = 'DejaVu\ Sans\ Mono\ for\ Powerline\ 11'

如果指定的字体不存在,将会使用系统默认的字体,此外,这一选项在终端下是无效的,终端下修改字体,需要修改终端自身配置。

界面元素切换

大多数界面元素可以通过快捷键来隐藏或者显示(这一组快捷键以 tT 开头):

快捷键 描述
SPC t 8 高亮所有超过 80 列的字符
SPC t f 高亮临界列,默认是第 80 列
SPC t h h 高亮当前行
SPC t h i 高亮代码对齐线
SPC t h c 高亮光标所在列
SPC t h s 启用/禁用语法高亮
SPC t i 切换显示当前对齐 (TODO)
SPC t n 显示/隐藏行号
SPC t b 切换背景色
SPC t t 打开 Tab 管理器
SPC T ~ 显示/隐藏 buffer 结尾空行行首的 ~
SPC T F 切换全屏 (TODO)
SPC T f 显示/隐藏 Vim 边框 (GUI)
SPC T m 显示/隐藏菜单栏
SPC T t 显示/隐藏工具栏

状态栏 & 标签栏

状态栏和工具栏是高度定制的模块,提供了如下特性:

  • 展示 buffer 或者 Tab 的序列号
  • 展示当前模式
  • 展示 git 相关信息
  • 展示语法检查信息
  • 展示 trailing line 的行号
  • 展示当前 SpaceVim 已启用的功能
  • 展示文件信息
  • 展示搜索结果序号
快捷键 描述
SPC [1-9] 跳至制定序号的窗口
状态栏

core#statusline 模块提供了一个高度定制的状态栏,提供如下特性,这一模块的灵感来自于 spacemacs 的状态栏。

  • 展示窗口序列号
  • 通过不同颜色展示当前模式
  • 展示搜索结果序列号
  • 显示/隐藏语法检查信息
  • 显示/隐藏电池信息
  • 显示/隐藏 SpaceVim 功能启用状态

默认主题 gruvbox 的状态栏颜色和模式对照表:

模式 颜色
Normal 灰色
Insert 蓝色
Visual 橙色
Replace 浅绿色

以上的这几种模式所对应的颜色取决于不同的主题模式。

一些状态栏元素可以进行动态的切换:

快捷键 描述
SPC t m b 显示/隐藏电池状态 (需要安装 acpi)
SPC t m c toggle the org task clock (available in org layer)(TODO)
SPC t m m 显示/隐藏 SpaceVim 已启用功能
SPC t m M 显示/隐藏文件类型
SPC t m n toggle the cat! (if colors layer is declared in your dotfile)(TODO)
SPC t m p 显示/隐藏鼠标位置信息
SPC t m t 显示/隐藏时间
SPC t m T 显示/隐藏状态栏
SPC t m v 显示/隐藏版本控制信息

Powerline 字体安装:

SpaceVim 默认使用 DejaVu Sans Mono for Powerline, 为了使状态栏得以正常显示,你需要安装这一字体。如果需要在状态栏中展示其他类型的分割符,则需要安装 powerline extra symbols.

语法检查信息:

状态栏中语法检查信息元素如果被启用了,当语法检查结束后,会在状态栏中展示当前语法错误和警告的数量。

TODO: add a picture

语法检查信息

搜索结果信息:

当使用 /? 进行搜索时,或当按下 nN 后,搜索结果序号将被展示在状态栏中,类似于 20/22 显示搜索结果总数以及当前结果的序号。具体的效果图如下:

search status

search index in statusline

电池状态信息:

acpi 可展示电池电量剩余百分比。

使用不同颜色展示不同的电池状态:

电池状态 颜色
75% - 100% 绿色
30% - 75% 黄色
0 - 30% 红色

所有的颜色都取决于不同的主题。

状态栏分割符:

可通过使用 g:spacevim_statusline_separator 来定制状态栏分割符,例如使用非常常用的方向箭头作为状态栏分割符:

let g:spacevim_statusline_separator = 'arrow'

SpaceVim 所支持的分割符以及截图如下:

分割符 截图
arrow separator-arrow
curve separator-curve
slant separator-slant
nil separator-nil
fire separator-fire

SpaceVim 功能模块:

功能模块可以通过 SPC t m m 快捷键显示或者隐藏。默认使用 Unicode 字符,可通过设置 let g:spacevim_statusline_unicode_symbols = 0 来启用 ASCII 字符。(或许在终端中无法设置合适的字体时,可使用这一选项)。

状态栏中功能模块内的字符显示与否,同如下快捷键功能保持一致:

快捷键 Unicode ASCII 功能
SPC t 8 8 高亮 80 列之后信息
SPC t f f 高亮第 80 列
SPC t s s 语法检查
SPC t S S 拼写检查
SPC t w w 行尾空格检查
标签栏

如果只有一个 Tab, Buffers 将被罗列在标签栏上,每一个包含:序号、文件类型图标、文件名。如果有不止一个 Tab, 那么所有 Tab 将被罗列在标签栏上。标签栏上每一个 Tab 或者 Baffer 可通过快捷键 <Leader> number 进行快速访问,默认的 <Leader>\

快捷键 描述
<Leader> 1 跳至标签栏序号 1
<Leader> 2 跳至标签栏序号 2
<Leader> 3 跳至标签栏序号 3
<Leader> 4 跳至标签栏序号 4
<Leader> 5 跳至标签栏序号 5
<Leader> 6 跳至标签栏序号 6
<Leader> 7 跳至标签栏序号 7
<Leader> 8 跳至标签栏序号 8
<Leader> 9 跳至标签栏序号 9

手册

自动补全

Unite/Denite

请阅读 unite 和 denite 文档: :h unite:h denite

Unite/Denite buffer 中的快捷键
快捷键 模式 功能描述
Ctrl+h/k/l/r Normal 无效
Ctrl+l Normal 刷新界面
Tab Insert 下一结果
Tab Normal 选择操作
Shift + Tab Insert 上一结果
Space Normal 标记当前结果
Enter Normal 执行默认操作
Ctrl+v Normal 在分割窗口中打开
Ctrl+s Normal 在垂直分割窗口打开
Ctrl+t Normal 在新 Tab 中打开
Ctrl + g Normal 推出 Unite/Denite
jk Insert 离开 Insert 模式
r Normal 重命名或者替换搜索内容
Ctrl+z Normal/insert 切换窗口布局
Ctrl+w Insert 删除前一单词

交互

快捷键
快捷键导航

当 Normal 模式下按下前缀键后出现输入延迟,则会在屏幕下方打开一个快捷键导航窗口,提示当前可用的快捷键及其功能描述,目前支持的前缀键有:[SPC][Window][Denite][Unite]<Leader>gz

这些前缀的按键为:

前缀名称 用户选项以及默认值 描述
[SPC] 空格键 SpaceVim 默认前缀键
[Window] g:spacevim_windows_leader / s SpaceVim 默认窗口前缀键
[denite] g:spacevim_denite_leader / F SpaceVim 默认 Denite 前缀键
[unite] g:spacevim_unite_leader / f SpaceVim 默认 Unite 前缀键
<leader> mapleader / \\ Vim/neovim 默认前缀键

默认情况下,快捷键导航将在输入延迟超过 1000ms 后打开,你可以通过修改 vim 的 'timeoutlen' 选项来修改成适合自己的延迟时间长度。

例如,Normal 模式下按下空格键,你将会看到:

mapping-guide

这一导航窗口将提示所有以空格键为前缀的快捷键,并且根据功能将这些快捷键进行了分组,例如 buffer 相关的快捷键都是 b,工程相关的快捷键都是 p。在代码导航窗口内,按下 <C-h> 键,可以获取一些帮助信息,这些信息将被显示在状态栏上,提示的是一些翻页和撤销按键的快捷键。

按键 描述
u 撤销按键
n 向下翻页
p 向上翻页

如果要自定义以 [SPC] 为前缀的快捷键,可以使用 SpaceVim#custom#SPC(),示例如下:

call SpaceVim#custom#SPC('nnoremap', ['f', 't'], 'echom "hello world"', 'test custom SPC', 1)
通过 Unite/Denite 浏览快捷键

可以通过 SPC ? 使用 Unite 将当前快捷键罗列出来。然后可以输入快捷键按键字母或者描述,Unite 可以通过模糊匹配,并展示结果。

unite-mapping

使用 <Tab> 键或者上下方向键选择你需要的快捷键,回车将执行这一快捷键。

获取帮助信息

Denite/Unite 是一个强大的信息筛选浏览器,这类似于 emacs 中的 Helm。以下这些快捷键将帮助你快速获取需要的帮助信息:

快捷键 描述
SPC h SPC 使用 Unite 展示 SpaceVim 帮助文档章节目录
SPC h i 获取光标下单词的帮助信息
SPC h k 使用快捷键导航,展示 SpaceVim 所支持的前缀键
SPC h m 使用 Unite 浏览所有 man 文档

报告一个问题:

快捷键 描述
SPC h I 根据模板展示 Issue 所必须的信息
可用模块

所有可用模块可以通过命令 SPLayer -l 或者快捷键 SPC h l 来展示。

可用的插件

可通过快捷键 <leader> l p 列出所有已安装的插件,支持模糊搜索,回车将使用浏览器打开该插件的官网。

添加用户自定义插件

如果添加来自于 github.com 的插件,可以 用户名/仓库名 这一格式,将该插件添加到 g:spacevim_custom_plugins,示例如下:

let g:spacevim_custom_plugins = [
    \ ['plasticboy/vim-markdown', {'on_ft' : 'markdown'}],
    \ ['wsdjeg/GitHub.vim'],
    \ ]

Toggles

both the toggles mappings started with [SPC] t or [SPC] T. you can find it in the mapping guide.

Point/Cursor

Navigation is performed using the Vi key bindings hjkl.

Key Binding Description
h move cursor left (origin vim key, no mappings)
j move cursor down (origin vim key, no mappings)
k move cursor up (origin vim key, no mappings)
l move cursor right (origin vim key, no mappings)
H move cursor to the top of the screen (origin vim key, no mappings)
L move cursor to the bottom of the screen (origin vim key, no mappings)
SPC j 0 go to the beginning of line (and set a mark at the previous location in the line)
SPC j $ go to the end of line (and set a mark at the previous location in the line)
SPC t - lock the cursor at the center of the screen

Vim motions with vim-easymotion

https://github.com/easymotion/vim-easymotion/issues/315

Similar to easymotion or f in vimperator for firefox, this mode allows one to jump to any link in help file with two key strokes.

mapping description
o initiate quick jump link mode in help buffer

Unimpaired bindings

Mappings Description
[ SPC Insert space above
] SPC Insert space below
[ b Go to previous buffer
] b Go to next buffer
[ f Go to previous file in directory
] f Go to next file in directory
[ l Go to the previous error
] l Go to the next error
[ c Go to the previous vcs hunk
] c Go to the next vcs hunk
[ q Go to the previous error
] q Go to the next error
[ t Go to the previous frame
] t Go to the next frame
[ w Go to the previous window
] w Go to the next window
[ e Move line up
] e Move line down
[ p Paste above current line
] p Paste below current line
g p Select pasted text

Jumping, Joining and Splitting

The SPC j prefix is for jumping, joining and splitting.

Jumping
Key Binding Description
SPC j 0 go to the beginning of line (and set a mark at the previous location in the line)
SPC j $ go to the end of line (and set a mark at the previous location in the line)
SPC j b jump backward
SPC j f jump forward
SPC j d jump to a listing of the current directory
SPC j D jump to a listing of the current directory (other window)
SPC j i jump to a definition in buffer (denite outline)
SPC j I jump to a definition in any buffer (denite outline)
SPC j j jump to a character in the buffer (easymotion)
SPC j J jump to a suite of two characters in the buffer (easymotion)
SPC j k jump to next line and indent it using auto-indent rules
SPC j l jump to a line with avy (easymotion)
SPC j q show the dumb-jump quick look tooltip (TODO)
SPC j u jump to a URL in the current window
SPC j v jump to the definition/declaration of an Emacs Lisp variable (TODO)
SPC j w jump to a word in the current buffer (easymotion)
Joining and splitting
Key Binding Description
J join the current line with the next line
SPC j k go to next line and indent it using auto-indent rules
SPC j n split the current line at point, insert a new line and auto-indent
SPC j o split the current line at point but let point on current line
SPC j s split a quoted string or s-expression in place
SPC j S split a quoted string or s-expression, insert a new line and auto-indent

Window manipulation

Window manipulation key bindings

Every window has a number displayed at the start of the statusline and can be quickly accessed using SPC number.

Key Binding Description
SPC 1 go to window number 1
SPC 2 go to window number 2
SPC 3 go to window number 3
SPC 4 go to window number 4
SPC 5 go to window number 5
SPC 6 go to window number 6
SPC 7 go to window number 7
SPC 8 go to window number 8
SPC 9 go to window number 9

Windows manipulation commands (start with w):

Key Binding Description
SPC w TAB switch to alternate window in the current frame (switch back and forth)
SPC w = balance split windows
SPC w b force the focus back to the minibuffer (TODO)
SPC w c Distraction-free reading current window
SPC w C Distraction-free reading other windows via vim-choosewin
SPC w d delete a window
SPC u SPC w d delete a window and its current buffer (does not delete the file) (TODO)
SPC w D delete another window using vim-choosewin
SPC u SPC w D delete another window and its current buffer using vim-choosewin (TODO)
SPC w t toggle window dedication (dedicated window cannot be reused by a mode) (TODO)
SPC w f toggle follow mode (TODO)
SPC w F create new tab(frame)
SPC w h move to window on the left
SPC w H move window to the left
SPC w j move to window below
SPC w J move window to the bottom
SPC w k move to window above
SPC w K move window to the top
SPC w l move to window on the right
SPC w L move window to the right
SPC w m maximize/minimize a window (maximize is equivalent to delete other windows) (TODO, now only support maximize)
SPC w M swap windows using vim-choosewin
SPC w o cycle and focus between tabs
SPC w p m open messages buffer in a popup window (TODO)
SPC w p p close the current sticky popup window (TODO)
SPC w r rotate windows forward
SPC w R rotate windows backward
SPC w s or SPC w - horizontal split
SPC w S horizontal split and focus new window
SPC w u undo window layout (used to effectively undo a closed window) (TODO)
SPC w U redo window layout (TODO)
SPC w v or SPC w / vertical split
SPC w V vertical split and focus new window
SPC w w cycle and focus between windows
SPC w W select window using vim-choosewin

Buffers and Files

Buffers manipulation key bindings

Buffer manipulation commands (start with b):

Key Binding Description
SPC TAB switch to alternate buffer in the current window (switch back and forth)
SPC b . buffer transient state
SPC b b switch to a buffer (via denite/unite)
SPC b d kill the current buffer (does not delete the visited file)
SPC u SPC b d kill the current buffer and window (does not delete the visited file) (TODO)
SPC b D kill a visible buffer using vim-choosewin
SPC u SPC b D kill a visible buffer and its window using ace-window(TODO)
SPC b C-d kill other buffers
SPC b C-D kill buffers using a regular expression(TODO)
SPC b e erase the content of the buffer (ask for confirmation)
SPC b h open SpaceVim home buffer
SPC b n switch to next buffer avoiding special buffers
SPC b m open Messages buffer
SPC u SPC b m kill all buffers and windows except the current one(TODO)
SPC b p switch to previous buffer avoiding special buffers
SPC b P copy clipboard and replace buffer (useful when pasting from a browser)
SPC b R revert the current buffer (reload from disk)
SPC b s switch to the scratch buffer (create it if needed)
SPC b w toggle read-only (writable state)
SPC b Y copy whole buffer to clipboard (useful when copying to a browser)
z f Make current function or comments visible in buffer as much as possible (TODO)
Create a new empty buffer
Key Binding Description
SPC b N h create new empty buffer in a new window on the left
SPC b N j create new empty buffer in a new window at the bottom
SPC b N k create new empty buffer in a new window above
SPC b N l create new empty buffer in a new window below
SPC b N n create new empty buffer in current window
Special Buffers

In SpaceVim, there are many special buffers, these buffers are created by plugins or SpaceVim isself. and all of this buffers are not listed.

Files manipulations key bindings

Files manipulation commands (start with f):

Key Binding Description
SPC f b go to file bookmarks
SPC f c copy current file to a different location(TODO)
SPC f C d convert file from unix to dos encoding
SPC f C u convert file from dos to unix encoding
SPC f D delete a file and the associated buffer (ask for confirmation)
SPC f E open a file with elevated privileges (sudo edit)(TODO)
SPC f f open file
SPC f F try to open the file under point
SPC f o open a file using the default external program(TODO)
SPC f R rename the current file(TODO)
SPC f s save a file
SPC f S save all files
SPC f r open a recent file
SPC f t toggle file tree side bar
SPC f T show file tree side bar
SPC f y show and copy current file absolute path in the cmdline
Vim and SpaceVim files

Convenient key bindings are located under the prefix SPC f v to quickly navigate between Vim and SpaceVim specific files.

Key Binding Description
SPC f v v display and copy SpaceVim version
SPC f v d open SpaceVim custom configuration file

File tree

SpaceVim use vimfiler as the default file tree, and the default key binding is F3, and SpaceVim also provide SPC f t and SPC f T to open the file tree. to change the file explore to nerdtree:

" the default value is vimfiler
let g:spacevim_filemanager = 'nerdtree'

VCS integration is supported, there will be a column status, this feature maybe make vimfiler slow, so it is not enabled by default. to enable this feature, add let g:spacevim_enable_vimfiler_gitstatus = 1 to your custom config. here is any picture for this feature:

file-tree

Navigation is centered on the hjkl keys with the hope of providing a fast navigation experience like in vifm:

Key Binding Description
<F3> or SPC f t Toggle file explorer
Within VimFiler buffers
<Left> or h go to parent node and collapse expanded directory
<Down> or j select next file or directory
<Up> or k select previous file or directory
<Right> or l open selected file or expand directory
Ctrl+j Un-map
Ctrl+l Un-map
E Un-map
. toggle visible ignored files
sv Split edit
sg Vertical split edit
p Preview
i Switch to directory history
v Quick look
gx Execute with vimfiler associated
' Toggle mark current line
V Clear all marks
Ctrl+r Redraw
Open file with file tree.

If there is only one file buffer opened, a file is opened in the active window, otherwise we need to use vim-choosewin to select a window to open the file.

Key Binding Description
l or Enter open file in one window
sg open file in an vertically split window
sv open file in an horizontally split window

Commands starting with g

after pressing prefix g in normal mode, if you do not remember the mappings, you will see the guide which will tell you the functional of all mappings starting with g.

Key Binding Description
g# search under cursor backward
g$ go to rightmost character
g& repeat last ":s" on all lines
g' jump to mark
g* search under cursor forward
g+ newer text state
g, newer position in change list
g- older text state
g/ stay incsearch
g0 go to leftmost character
g; older position in change list
g< last page of previous command output
g<Home> go to leftmost character
gE end of previous word
gF edit file under cursor(jump to line after name)
gH select line mode
gI insert text in column 1
gJ join lines without space
gN visually select previous match
gQ switch to Ex mode
gR enter VREPLACE mode
gT previous tag page
gU make motion text uppercase
g] tselect cursor tag
g^ go to leftmost no-white character
g_ go to last char
g` jump to mark
ga print ascii value of cursor character
gd goto definition
ge go to end of previous word
gf edit file under cursor
gg go to line N
gh select mode
gi insert text after '^ mark
gj move cursor down screen line
gk move cursor up screen line
gm go to middle of screenline
gn visually select next match
go goto byte N in the buffer
gs sleep N seconds
gt next tag page
gu make motion text lowercase
g~ swap case for Nmove text
g<End> go to rightmost character
g<C-G> show cursor info

Commands starting with z

after pressing prefix z in normal mode, if you do not remember the mappings, you will see the guide which will tell you the functional of all mappings starting with z.

Key Binding Description
z<Right> scroll screen N characters to left
z+ cursor to screen top line N
z- cursor to screen bottom line N
z. cursor line to center
z<CR> cursor line to top
z= spelling suggestions
zA toggle folds recursively
zC close folds recursively
zD delete folds recursively
zE eliminate all folds
zF create a fold for N lines
zG mark good spelled(update internal-wordlist)
zH scroll half a screenwidth to the right
zL scroll half a screenwidth to the left
zM set foldlevel to zero
zN set foldenable
zO open folds recursively
zR set foldlevel to deepest fold
zW mark wrong spelled
zX re-apply foldleve
z^ cursor to screen bottom line N
za toggle a fold
zb redraw, cursor line at bottom
zc close a fold
zd delete a fold
ze right scroll horizontally to cursor position
zf create a fold for motion
zg mark good spelled
zh scroll screen N characters to right
zi toggle foldenable
zj mode to start of next fold
zk mode to end of previous fold
zl scroll screen N characters to left
zm subtract one from foldlevel
zn reset foldenable
zo open fold
zr add one to foldlevel
zs left scroll horizontally to cursor position
zt cursor line at top of window
zv open enough folds to view cursor line
zx re-apply foldlevel and do "zV"
zz smart scroll
z<Left> scroll screen N characters to right

Auto-saving

Searching

With an external tool

SpaceVim can be interfaced with different searching tools like:

The search commands in SpaceVim are organized under the SPC s prefix with the next key is the tool to use and the last key is the scope. For instance SPC s a b will search in all opened buffers using ag.

If the last key (determining the scope) is uppercase then the current word under the cursor is used as default input for the search. For instance SPC s a B will search with word under cursor.

If the tool key is omitted then a default tool will be automatically selected for the search. This tool corresponds to the first tool found on the system of the list g:spacevim_search_tools, the default order is rg, ag, pt, ack then grep. For instance SPC s b will search in the opened buffers using pt if rg and ag have not been found on the system.

The tool keys are:

Tool Key
ag a
grep g
ack k
rg r
pt t

The available scopes and corresponding keys are:

Scope Key
opened buffers b
files in a given directory f
current project p

It is possible to search in the current file by double pressing the second key of the sequence, for instance SPC s a a will search in the current file with ag.

Notes:

  • rg, ag and pt are optimized to be used in a source control repository but they can be used in an arbitrary directory as well.
  • It is also possible to search in several directories at once by marking them in the unite buffer.

Beware if you use pt, TCL parser tools also install a command line tool called pt.

Useful key bindings
Key Binding Description
SPC r l resume the last completion buffer
SPC s ` go back to the previous place before jump
Prefix argument will ask for file extensions
Searching in current file
Key Binding Description
SPC s s search with the first found tool
SPC s S search with the first found tool with default input
SPC s a a ag
SPC s a A ag with default input
SPC s g g grep
SPC s g G grep with default input
SPC s r r rg
SPC s r R rg with default input
Searching in all loaded buffers
Key Binding Description
SPC s b search with the first found tool
SPC s B search with the first found tool with default input
SPC s a b ag
SPC s a B ag with default input
SPC s g b grep
SPC s g B grep with default input
SPC s k b ack
SPC s k B ack with default input
SPC s r b rg
SPC s r B rg with default input
SPC s t b pt
SPC s t B pt with default input
Searching in an arbitrary directory
Key Binding Description
SPC s f search with the first found tool
SPC s F search with the first found tool with default input
SPC s a f ag
SPC s a F ag with default text
SPC s g f grep
SPC s g F grep with default text
SPC s k f ack
SPC s k F ack with default text
SPC s r f rg
SPC s r F rg with default text
SPC s t f pt
SPC s t F pt with default text
Searching in a project
Key Binding Description
SPC / or SPC s p search with the first found tool
SPC * or SPC s P search with the first found tool with default input
SPC s a p ag
SPC s a P ag with default text
SPC s g p grep
SPC s g p grep with default text
SPC s k p ack
SPC s k P ack with default text
SPC s t p pt
SPC s t P pt with default text
SPC s r p rg
SPC s r P rg with default text

Hint: It is also possible to search in a project without needing to open a file beforehand. To do so use SPC p p and then C-s on a given project to directly search into it like with SPC s p. (TODO)

Background searching in a project

Background search keyword in a project, when searching done, the count will be shown on the statusline.

Key Binding Description
SPC s j searching input expr background with the first found tool
SPC s J searching cursor word background with the first found tool
SPC s l List all searching result in quickfix buffer
SPC s a j ag
SPC s a J ag with default text
SPC s g j grep
SPC s g J grep with default text
SPC s k j ack
SPC s k J ack with default text
SPC s t j pt
SPC s t J pt with default text
SPC s r j rg
SPC s r J rg with default text
Searching the web
Key Binding Description
SPC s w g Get Google suggestions in vim. Opens Google results in Browser.
SPC s w w Get Wikipedia suggestions in vim. Opens Wikipedia page in Browser.(TODO)

Note: to enable google suggestions in vim, you need to add let g:spacevim_enable_googlesuggest = 1 to your custom Configuration file.

Searching on the fly

Key Binding Description
SPC s g G Searching in project on the fly with default tools

key binding in FlyGrep buffer:

Key Binding Description -----------| ----------- <Esc> | close FlyGrep buffer <Enter> | open file at the cursor line <Tab> | move cursor line down <S-Tab> | move cursor line up <Bs> | remove last character <C-w> | remove the Word before the cursor <C-u> | remove the Line before the cursor <C-k> | remove the Line after the cursor <C-a>/<Home> | Go to the beginning of the line <C-e>/<End> | Go to the end of the line

Persistent highlighting

SpaceVim uses g:spacevim_search_highlight_persist to keep the searched expression highlighted until the next search. It is also possible to clear the highlighting by pressing SPC s c or executing the ex command :noh.

Editing

Paste text

Auto-indent pasted text

Text manipulation commands

Text related commands (start with x):

Key Binding Description
SPC x a & align region at &
SPC x a ( align region at (
SPC x a ) align region at )
SPC x a [ align region at [
SPC x a ] align region at ]
SPC x a { align region at {
SPC x a } align region at }
SPC x a , align region at ,
SPC x a . align region at . (for numeric tables)
SPC x a : align region at :
SPC x a ; align region at ;
SPC x a = align region at =
SPC x a ¦ align region at ¦
SPC x a a align region (or guessed section) using default rules (TODO)
SPC x a c align current indentation region using default rules (TODO)
SPC x a l left-align with evil-lion (TODO)
SPC x a L right-align with evil-lion (TODO)
SPC x a r align region using user-specified regexp (TODO)
SPC x a m align region at arithmetic operators (+-*/) (TODO)
SPC x c count the number of chars/words/lines in the selection region
SPC x d w delete trailing whitespaces
SPC x d SPC Delete all spaces and tabs around point, leaving one space
SPC x g l set lanuages used by translate commands (TODO)
SPC x g t translate current word using Google Translate
SPC x g T reverse source and target languages (TODO)
SPC x i c change symbol style to lowerCamelCase
SPC x i C change symbol style to UpperCamelCase
SPC x i i cycle symbol naming styles (i to keep cycling)
SPC x i - change symbol style to kebab-case
SPC x i k change symbol style to kebab-case
SPC x i _ change symbol style to under_score
SPC x i u change symbol style to under_score
SPC x i U change symbol style to UP_CASE
SPC x j c set the justification to center (TODO)
SPC x j f set the justification to full (TODO)
SPC x j l set the justification to left (TODO)
SPC x j n set the justification to none (TODO)
SPC x j r set the justification to right (TODO)
SPC x J move down a line of text (enter transient state)
SPC x K move up a line of text (enter transient state)
SPC x l d duplicate line or region (TODO)
SPC x l s sort lines (TODO)
SPC x l u uniquify lines (TODO)
SPC x o use avy to select a link in the frame and open it (TODO)
SPC x O use avy to select multiple links in the frame and open them (TODO)
SPC x t c swap (transpose) the current character with the previous one
SPC x t w swap (transpose) the current word with the previous one
SPC x t l swap (transpose) the current line with the previous one
SPC x u set the selected text to lower case (TODO)
SPC x U set the selected text to upper case (TODO)
SPC x w c count the number of occurrences per word in the select region (TODO)
SPC x w d show dictionary entry of word from wordnik.com (TODO)
SPC x TAB indent or dedent a region rigidly (TODO)

Text insertion commands

Text insertion commands (start with i):

Key binding Description
SPC i l l insert lorem-ipsum list
SPC i l p insert lorem-ipsum paragraph
SPC i l s insert lorem-ipsum sentence
SPC i p 1 insert simple password
SPC i p 2 insert stronger password
SPC i p 3 insert password for paranoids
SPC i p p insert a phonetically easy password
SPC i p n insert a numerical password
SPC i u Search for Unicode characters and insert them into the active buffer.
SPC i U 1 insert UUIDv1 (use universal argument to insert with CID format)
SPC i U 4 insert UUIDv4 (use universal argument to insert with CID format)
SPC i U U insert UUIDv4 (use universal argument to insert with CID format)

Commenting

Comments are handled by nerdcommenter, it’s bound to the following keys.

Key Binding Description
SPC ; comment operator
SPC c h hide/show comments
SPC c l comment lines
SPC c L invert comment lines
SPC c p comment paragraphs
SPC c P invert comment paragraphs
SPC c t comment to line
SPC c T invert comment to line
SPC c y comment and yank
SPC c Y invert comment and yank

Tips: To comment efficiently a block of line use the combo SPC ; SPC j l

dev

Multi-Encodings

SpaceVim use utf-8 as default encoding. there are four options for these case:

  • fileencodings (fencs): ucs-bom,utf-8,default,latin1
  • fileencoding (fenc): utf-8
  • encoding (enc): utf-8
  • termencoding (tenc): utf-8 (only supported in vim)

to fix messy display: SPC e a is the mapping for auto detect the file encoding. after detecting file encoding, you can run the command below to fix the encoding:

set enc=utf-8
write

Errors handling

SpaceVim uses neomake to gives error feedback on the fly. The checks are only performed at save time by default.

Errors management mappings (start with e):

Mappings Description
SPC t s toggle syntax checker
SPC e c clear all errors
SPC e h describe a syntax checker
SPC e l toggle the display of the list of errors/warnings
SPC e n go to the next error
SPC e p go to the previous error
SPC e v verify syntax checker setup (useful to debug 3rd party tools configuration)
SPC e . error transient state

The next/previous error mappings and the error transient state can be used to browse errors from syntax checkers as well as errors from location list buffers, and indeed anything that supports vim's location list. This includes for example search results that have been saved to a location list buffer.

Custom sign symbol:

Symbol Description Custom option
Error g:spacevim_error_symbol
warning g:spacevim_warning_symbol

Managing projects

Projects in SpaceVim are managed by vim-projectionist and vim-rooter, vim-rooter will find the root of the project when a .git directory or a .projections.json file is encountered in the file tree.

project manager commands start with p:

Key Binding Description
SPC p ' open a shell in project’s root (with the shell layer)

Achievements

issues

Achievements Account
100th issue(issue) BenBergman

Stars, forks and watchers

Achievements Account
First stargazers monkeydterry
100th stargazers naraj
1000th stargazers icecity96
2000th stargazers frowhy
3000th stargazers purkylin

Features

Awesome ui

  • outline + filemanager + checker

awesome ui

Mnemonic key bindings

Key bindings are organized using mnemonic prefixes like b for buffer, p for project, s for search, h for help, etc…

SPC mapping root : SPC means <Space> on the keyboard.

Key Description
SPC ! shell cmd
SPC a +applications
SPC b +buffers
SPC 1...9 windows 1...9

Language specific mode

Key Mapping

c/c++ support

  1. code completion: autocompletion and fuzzy match. completion-fuzzy-match
  2. syntax check: Asynchronous linting and make framework. syntax-check

go support

  1. code completion: 2017-02-01_1360x721
  2. syntax check: 2017-02-01_1359x720

python support

  1. code completion: 2017-02-02_1360x724
  2. syntax check: 2017-02-02_1358x720

Neovim centric - Dark powered mode of SpaceVim.

By default, SpaceVim use these dark powered plugins:

  1. deoplete.nvim - Dark powered asynchronous completion framework for neovim
  2. dein.vim - Dark powered Vim/Neovim plugin manager

TODO:

  1. defx.nvim - Dark powered file explorer
  2. deoppet.nvim - Dark powered snippet plugin
  3. denite.nvim - Dark powered asynchronous unite all interfaces for Neovim/Vim8

Modular configuration

Multiple leader mode

Global origin vim leader

Vim's origin global leader can be used in all modes.

Local origin vim leader

Vim's origin local leader can be used in all the mode.

Windows function leader

Windows function leader can only be used in normal mode. For the list of mappings see the link

Unite work flow leader

Unite work flow leader can only be used in normal mode. Unite leader need unite groups.

Unite centric work-flow

unite

  • List all the plugins has been installed, fuzzy find what you want, default action is open the github website of current plugin. default key is <leader>lp 2017-01-21_1358x725

  • List all the mappings and description: f<space> 2017-02-01_1359x723

  • List all the starred repos in github.com, fuzzy find and open the website of the repo. default key is <leader>ls 2017-02-01_1359x722

Plugin Highlights

  • Package management with caching enabled and lazy loading
  • Project-aware tabs and label
  • Vimfiler as file-manager + SSH connections
  • Go completion via vim-go and gocode
  • Javascript completion via Tern
  • PHP completion, indent, folds, syntax
  • Python jedi completion, pep8 convention
  • Languages: Ansible, css3, csv, json, less, markdown, mustache
  • Helpers: Undo tree, bookmarks, git, tmux navigation, hex editor, sessions, and much more.

    Note that 90% of the plugins are [lazy-loaded].

    [lazy-loaded]: ./config/plugins.vim

Non Lazy-Loaded Plugins

Name Description
[dein.vim] Dark powered Vim/Neovim plugin manager
[vimproc] Interactive command execution
[colorschemes] Awesome color-schemes
[file-line] Allow opening a file in a given line
[neomru] MRU source for Unite
[cursorword] Underlines word under cursor
[gitbranch] Lightweight git branch detection
[gitgutter] Shows git diffs in the gutter
[tinyline] Tiny great looking statusline
[tagabana] Central location for all tags
[bookmarks] Bookmarks, works independently from vim marks
[tmux-navigator] Seamless navigation between tmux panes and vim splits

Lazy-Loaded Plugins

Language

Name Description
[html5] HTML5 omnicomplete and syntax
[mustache] Mustache and handlebars syntax
[markdown] Markdown syntax highlighting
[ansible-yaml] Additional support for Ansible
[jinja] Jinja support in vim
[less] Syntax for LESS
[css3-syntax] CSS3 syntax support to vim's built-in syntax/css.vim
[csv] Handling column separated data
[pep8-indent] Nicer Python indentation
[logstash] Highlights logstash configuration files
[tmux] vim plugin for tmux.conf
[json] Better JSON support
[toml] Syntax for TOML
[i3] i3 window manager config syntax
[Dockerfile] syntax and snippets for Dockerfile
[go] Go development
[jedi-vim] Python jedi autocompletion library
[ruby] Ruby configuration files
[portfile] Macports portfile configuration files
[javascript] Enhanced Javascript syntax
[javascript-indent] Javascript indent script
[tern] Provides Tern-based JavaScript editing support
[php] Up-to-date PHP syntax file
[phpfold] PHP folding
[phpcomplete] Improved PHP omnicompletion
[phpindent] PHP official indenting
[phpspec] PhpSpec integration
Commands
Name Description
[vimfiler] Powerful file explorer
[NERD Commenter] Comment tool - no comment necessary
[vinarise] Hex editor
[syntastic] Syntax checking hacks
[gita] An awesome git handling plugin
[gista] Manipulate gists in Vim
[undotree] Ultimate undo history visualizer
[incsearch] Improved incremental searching
[expand-region] Visually select increasingly larger regions of text
[open-browser] Open URI with your favorite browser
[prettyprint] Pretty-print vim variables
[quickrun] Run commands quickly
[ref] Integrated reference viewer
[dictionary] Dictionary.app interface
[vimwiki] Personal Wiki for Vim
[thesaurus] Look up words in an online thesaurus
Commands
Name Description
[goyo] Distraction-free writing
[limelight] Hyperfocus-writing
[matchit] Intelligent pair matching
[indentline] Display vertical indention lines
[choosewin] Choose window to use, like tmux's 'display-pane'
Completion
Name Description
[delimitmate] Insert mode auto-completion for quotes, parenthesis, brackets
[echodoc] Print objects' documentation in echo area
[deoplete] Neovim: Dark powered asynchronous completion framework
[neocomplete] Next generation completion framework
[neosnippet] Contains neocomplete snippets source
Unite
Name Description
[unite] Unite and create user interfaces
[unite-colorscheme] Browse colorschemes
[unite-filetype] Select file type
[unite-history] Browse history of command/search
[unite-build] Build with Unite interface
[unite-outline] File "outline" source for unite
[unite-tag] Tags source for Unite
[unite-quickfix] Quickfix source for Unite
[neossh] SSH interface for plugins
[unite-pull-request] GitHub pull-request source for Unite
[junkfile] Create temporary files for memo and testing
[unite-issue] Issue manager for JIRA and GitHub
Operators & Text Objects
Name Description
[operator-user] Define your own operator easily
[operator-replace] Operator to replace text with register content
[operator-surround] Operator to enclose text objects
[textobj-user] Create your own text objects
[textobj-multiblock] Handle multiple brackets objects

Custom Key bindings

Key Mode Action
<leader>+y visual Copy selection to X11 clipboard ("+y)
Ctrl+c Normal Copy full path of current buffer to X11 clipboard
<leader>+Ctrl+c Normal Copy github.com url of current buffer to X11 clipboard(if it is a github repo)
<leader>+Ctrl+l Normal/visual Copy github.com url of current lines to X11 clipboard(if it is a github repo)
<leader>+p Normal/visual Paste selection from X11 clipboard ("+p)
Ctrl+f Normal Smart page forward (C-f/C-d)
Ctrl+b Normal Smart page backwards (C-b/C-u)
Ctrl+e Normal Smart scroll down (3C-e/j)
Ctrl+y Normal Smart scroll up (3C-y/k)
Ctrl+q Normal Ctrl+w
Ctrl+x Normal Switch buffer and placement
Up,Down Normal Smart up and down
} Normal After paragraph motion go to first non-blank char (}^)
< Visual/Normal Indent to left and re-select
> Visual/Normal Indent to right and re-select
Tab Visual Indent to right and re-select
Shift+Tab Visual Indent to left and re-select
gp Normal Select last paste
Q/gQ Normal Disable EX-mode ()
Ctrl+a Command Navigation in command line
Ctrl+b Command Move cursor backward in command line
Ctrl+f Command Move cursor forward in command line
File Operations
Key Mode Action
<leader>+cd Normal Switch to the directory of the open buffer
<leader>+w Normal/visual Write (:w)
Ctrl+s Normal/visual/Command Write (:w)
:w!! Command Write as root (%!sudo tee > /dev/null %)
Editor UI
Key Mode Action
F2 All Toggle tagbar
F3 All Toggle Vimfiler
<leader> + num Normal Jump to the buffer whit the num index
<Alt> + num Normal Jump to the buffer whit the num index, this only works in neovim
<Alt> + h/<Left> Normal Jump to left buffer in the tabline, this only works in neovim
<Alt> + l/<Right> Normal Jump to Right buffer in the tabline, this only works in neovim
<leader>+ts Normal Toggle spell-checker (:setlocal spell!)
<leader>+tn Normal Toggle line numbers (:setlocal nonumber!)
<leader>+tl Normal Toggle hidden characters (:setlocal nolist!)
<leader>+th Normal Toggle highlighted search (:set hlsearch!)
<leader>+tw Normal Toggle wrap (:setlocal wrap! breakindent!)
g0 Normal Go to first tab (:tabfirst)
g$ Normal Go to last tab (:tablast)
gr Normal Go to previous tab (:tabprevious)
Ctrl+<Dow> Normal Move to split below (j)
Ctrl+<Up> Normal Move to upper split (k)
Ctrl+<Left> Normal Move to left split (h)
Ctrl+<Right> Normal Move to right split (l)
* Visual Search selection forwards
# Visual Search selection backwards
,+Space Normal Remove all spaces at EOL
Ctrl+r Visual Replace selection
<leader>+lj Normal Next on location list
<leader>+lk Normal Previous on location list
<leader>+S Normal/visual Source selection
Window Management
Key Mode Action
q Normal Smart buffer close
s+p Normal Split nicely
s+v Normal :split
s+g Normal :vsplit
s+t Normal Open new tab (:tabnew)
s+o Normal Close other windows (:only)
s+x Normal Remove buffer, leave blank window
s+q Normal Closes current buffer (:close)
s+Q Normal Removes current buffer, left buffer in the tabline will be displayed, if there is no buffer on the left, the right buffer will be displayed, if this is the last buffer in the tabline, then an empty buffer will be displayed.
Tab Normal Next window or tab
Shift+Tab Normal Previous window or tab
<leader>+sv Normal Split with previous buffer
<leader>+sg Normal Vertical split with previous buffer

SpaceVim has mapped normal q as smart buffer close, the normal func of q can be get by <leader> q r

Native functions
Key Mode Action
<leader> + qr Normal Same as native q
<leader> + qr/ Normal Same as native q/, open cmdwin
<leader> + qr? Normal Same as native q?, open cmdwin
<leader> + qr: Normal Same as native q:, open cmdwin
Plugin: Unite
Key Mode Action
[unite] Normal unite leader, default is f, :h g:spacevim_unite_leader
[unite]+r Normal Resumes Unite window
[unite]+f Normal Opens Unite file recursive search
[unite]+i Normal Opens Unite git file search
[unite]+g Normal Opens Unite grep with ag (the_silver_searcher)
[unite]+u Normal Opens Unite source
[unite]+t Normal Opens Unite tag
[unite]+T Normal Opens Unite tag/include
[unite]+l Normal Opens Unite location list
[unite]+q Normal Opens Unite quick fix
[unite]+e Normal Opens Unite register
[unite]+j Normal Opens Unite jump, change
[unite]+h Normal Opens Unite history/yank
[unite]+s Normal Opens Unite session
[unite]+n Normal Opens Unite session/new
[unite]+o Normal Opens Unite outline
[unite]+c Normal Opens Unite buffer bookmark file in current directory
[unite]+b Normal Opens Unite buffer bookmark file in buffer directory
[unite]+ma Normal Opens Unite mapping
[unite]+<space> Normal Opens Unite menu:CustomKeyMaps
[unite]+me Normal Opens Unite output messages
<leader>+bl Normal Opens Unite buffers, mru, bookmark
<leader>+ta Normal Opens Unite tab
<leader>+ugf Normal Opens Unite file with word at cursor
<leader>+ugt Normal/visual Opens Unite tag with word at cursor
Plugin: neocomplete
Key Mode Action
Enter Insert Smart snippet expansion
Ctrl+space Insert Autocomplete with Unite
Tab Insert/select Smart tab movement or completion
Ctrl+j/k/f/b Insert Movement in popup
Ctrl+g Insert Undo completion
Ctrl+l Insert Complete common string
Ctrl+o Insert Expand snippet
Ctrl+y Insert Close pop-up
Ctrl+e Insert Close pop-up
Ctrl+l Insert Complete common string
Ctrl+d Insert Scroll down
Ctrl+u Insert Scroll up
Plugin: NERD Commenter
Key Mode Action
<leader>+cc Normal/visual Comment out the current line or text selected in visual mode.
<leader>+cn Normal/visual Same as cc but forces nesting.
<leader>+cu Normal/visual Uncomments the selected line(s).
<leader>+cs Normal/visual Comments out the selected lines with a pretty block formatted layout.
<leader>+cy Normal/visual Same as cc except that the commented line(s) are yanked first.
Plugin: Goyo and Limelight
Key Mode Action
<leader>+G Normal Toggle distraction-free writing
Plugin: ChooseWin
Key Mode Action
- Normal Choose a window to edit
<leader>+- Normal Switch editing window with selected
Plugin: Bookmarks
Key Mode Action
m+a Normal Show list of all bookmarks
m+m Normal Toggle bookmark in current line
m+n Normal Jump to next bookmark
m+p Normal Jump to previous bookmark
m+i Normal Annotate bookmark

As SpaceVim use above bookmarks mappings, so you can not use a, m, n, p or i registers to mark current position, but other registers should works will. if you really need to use these registers, you can add nnoremap <leader>m m to your custom configuration, then you use use a registers via \ma

Plugin: Gina/Gita
Key Mode Action
<leader>+gs Normal Git status
<leader>+gd Normal Git diff
<leader>+gc Normal Git commit
<leader>+gb Normal Git blame
<leader>+gp Normal Git push
<leader>+ga Normal Git add current buffer
<leader>+gA Normal Git add all files
Plugin: vim-signify
Key Mode Action
<leader>+hj / ]c Normal Jump to next hunk
<leader>+hk / [c Normal Jump to previous hunk
<leader>+hJ / ]C Normal Jump to last hunk
<leader>+hK / [C Normal Jump to first hunk
Misc Plugins
Key Mode Action
<leader>+gu Normal Open undo tree
<leader>+i Normal Toggle indentation lines
<leader>+j Normal Start smalls
<leader>+r Normal Quickrun
<leader>+? Normal Dictionary
<leader>+W Normal Wiki
<leader>+K Normal Thesaurus

[dein.vim]: https://github.com/Shougo/dein.vim

[vimproc]: https://github.com/Shougo/vimproc.vim

[colorschemes]: https://github.com/rafi/awesome-vim-colorschemes

[file-line]: https://github.com/bogado/file-line

[neomru]: https://github.com/Shougo/neomru.vim

[cursorword]: https://github.com/itchyny/vim-cursorword

[gitbranch]: https://github.com/itchyny/vim-gitbranch

[gitgutter]: https://github.com/airblade/vim-gitgutter

[bookmarks]: https://github.com/MattesGroeger/vim-bookmarks

[tmux-navigator]: https://github.com/christoomey/vim-tmux-navigator

[tinyline]: https://github.com/rafi/vim-tinyline

[tagabana]: https://github.com/rafi/vim-tagabana

[html5]: https://github.com/othree/html5.vim

[mustache]: https://github.com/mustache/vim-mustache-handlebars

[markdown]: https://github.com/rcmdnk/vim-markdown

[ansible-yaml]: https://github.com/chase/vim-ansible-yaml

[jinja]: https://github.com/mitsuhiko/vim-jinja

[less]: https://github.com/groenewege/vim-less

[css3-syntax]: https://github.com/hail2u/vim-css3-syntax

[csv]: https://github.com/chrisbra/csv.vim

[pep8-indent]: https://github.com/hynek/vim-python-pep8-indent

[logstash]: https://github.com/robbles/logstash.vim

[tmux]: https://github.com/tmux-plugins/vim-tmux

[json]: https://github.com/elzr/vim-json

[toml]: https://github.com/cespare/vim-toml

[i3]: https://github.com/PotatoesMaster/i3-vim-syntax

[dockerfile]: https://github.com/ekalinin/Dockerfile.vim

[go]: https://github.com/fatih/vim-go

[jedi-vim]: https://github.com/davidhalter/jedi-vim

[ruby]: https://github.com/vim-ruby/vim-ruby

[portfile]: https://github.com/jstrater/mpvim

[javascript]: https://github.com/jelera/vim-javascript-syntax

[javascript-indent]: https://github.com/jiangmiao/simple-javascript-indenter

[tern]: https://github.com/marijnh/tern_for_vim

[php]: https://github.com/StanAngeloff/php.vim

[phpfold]: https://github.com/rayburgemeestre/phpfolding.vim

[phpcomplete]: https://github.com/shawncplus/phpcomplete.vim

[phpindent]: https://github.com/2072/PHP-Indenting-for-VIm

[phpspec]: https://github.com/rafi/vim-phpspec

[vimfiler]: https://github.com/Shougo/vimfiler.vim

[tinycomment]: https://github.com/rafi/vim-tinycomment

[vinarise]: https://github.com/Shougo/vinarise.vim

[syntastic]: https://github.com/scrooloose/syntastic

[gita]: https://github.com/lambdalisue/vim-gita

[gista]: https://github.com/lambdalisue/vim-gista

[undotree]: https://github.com/mbbill/undotree

[incsearch]: https://github.com/haya14busa/incsearch.vim

[expand-region]: https://github.com/terryma/vim-expand-region

[open-browser]: https://github.com/tyru/open-browser.vim

[prettyprint]: https://github.com/thinca/vim-prettyprint

[quickrun]: https://github.com/thinca/vim-quickrun

[ref]: https://github.com/thinca/vim-ref

[dictionary]: https://github.com/itchyny/dictionary.vim

[vimwiki]: https://github.com/vimwiki/vimwiki

[thesaurus]: https://github.com/beloglazov/vim-online-thesaurus

[goyo]: https://github.com/junegunn/goyo.vim

[limelight]: https://github.com/junegunn/limelight.vim

[matchit]: http://www.vim.org/scripts/script.php?script_id=39

[indentline]: https://github.com/Yggdroot/indentLine

[choosewin]: https://github.com/t9md/vim-choosewin

[delimitmate]: https://github.com/Raimondi/delimitMate

[echodoc]: https://github.com/Shougo/echodoc.vim

[deoplete]: https://github.com/Shougo/deoplete.nvim

[neocomplete]: https://github.com/Shougo/neocomplete.vim

[neosnippet]: https://github.com/Shougo/neosnippet.vim

[unite]: https://github.com/Shougo/unite.vim

[unite-colorscheme]: https://github.com/ujihisa/unite-colorscheme

[unite-filetype]: https://github.com/osyo-manga/unite-filetype

[unite-history]: https://github.com/thinca/vim-unite-history

[unite-build]: https://github.com/Shougo/unite-build

[unite-outline]: https://github.com/h1mesuke/unite-outline

[unite-tag]: https://github.com/tsukkee/unite-tag

[unite-quickfix]: https://github.com/osyo-manga/unite-quickfix

[neossh]: https://github.com/Shougo/neossh.vim

[unite-pull-request]: https://github.com/joker1007/unite-pull-request

[junkfile]: https://github.com/Shougo/junkfile.vim

[unite-issue]: https://github.com/rafi/vim-unite-issue

[operator-user]: https://github.com/kana/vim-operator-user

[operator-replace]: https://github.com/kana/vim-operator-replace

[operator-surround]: https://github.com/rhysd/vim-operator-surround

[textobj-user]: https://github.com/kana/vim-textobj-user

[textobj-multiblock]: https://github.com/osyo-manga/vim-textobj-multiblock

模块化配置

SpaceVim 是由多个独立模块组成的配置集合,针对不同的功能需求,设计了多个模块,用户在使用的时候只需要载入相应的模块即可。比如对于 Java 开发者,载入 lang#javaautocompletecheckertags模块即可配置出一个适合 Java 开发的 Vim 环境。

SpaceVim 支持的模:http://spacevim.org/layers/

Denite/Unite为主的工作平台

Unite 的快捷键前缀是f,可以通过 g:spacevim_unite_leader 来设定,快捷键无需记忆,SpaceVim 有很好的快捷键辅助机制,如下是 Unite 的快捷键键图:

unite

Denite 是新一代的插件,相比 Unite 速度更加快,安装也更加方便。的快捷键前缀是F,可以通过 g:spacevim_denite_leader 来设定。

自动补全

SpaceVim 采用最快补全引擎 deoplete, 该引擎不同与 YouCompleteMe 的主要一点是支持多源补全,而不单单是语义补全。而且补全来源拓展非常方便。

细致的 tags 管理

快速

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 `<Leader>`
let mapleader = "\<space>"

" 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 选项

选项名称 默认值 描述
g:spacevim_default_indent 2 对齐空格
g:spacevim_enable_guicolors 1 启用/禁用终端使用真色彩
g:spacevim_windows_leader s 窗口管理快捷键前缀
g:spacevim_unite_leader f Unite 快捷键前缀
g:spacevim_plugin_bundle_dir ~/.cache/vimfiles 默认插件缓存位置
g:spacevim_realtime_leader_guide 0 启用/禁用实时快捷键提示
g:spacevim_guifont '' 设置 SpaceVim 字体
g:spacevim_sidebar_width 30 设置边栏宽度,文件树以及语法树
g:spacevim_custom_plugins [] 设置自定义插件

这个又是什么?不是同一个人么?

https://ruby-china.org/topics/31834

#1 楼 @huacnlee 完全不是,我的配置原始仓库老早就开始搞了,只是一开始没有将 vim 的配置独立出来,现在独立出来,放到 github 组织里面搞了。

建议两位作者交流下,合二为一!

一直在用 spacemacs

#1 楼 @huacnlee #4 楼 @stephen

我的语言风格显然不同~ 😭

如果没有使用过 spacemacs, 那么我想其间的理念很难一致。之所以写了 space-vim, 就是因为不太喜欢已有的 spacevim, 我觉得它在借鉴 spacemacs 的基础上不够 high level,在整体的效果上也不够漂亮与优雅。

漂亮,主观成分比较大,各凭喜好。优雅,不是繁复,复杂,亦非简单,简陋,而是简约,清丽。

俗话说,不经过调查就没有发言权。如果不使用过 spacemacs, 很难体会个中滋味。仅是从表面看,我想很难了解其细微之处。我是一个注重外表与细节体验的人,不喜欢太复杂,更不喜欢简陋。

这只是我的个人配置,just a side project。分享出来,如果有大家喜欢,那很好,也说明其品质。如果有问题,我也期待共同讨论解决。这是一个相互学习与提高的过程,双赢的过程。

我有自己的事情,不会做与很多无用功,不会特意花很多时间消磨在这种工具上,只会按需打理。作为一个 open source project, 如果你觉得其有可重塑的价值,完全可以 fork 一份把它变成任何模样,这完全取决你自己。当然,如果你有好的想法并愿意分享,PR 也是时刻敞开的。

vim, spacemacs, IDE, 绝不冲突,解决问题才是根本。也许这些东西能够给你挣得一些 star, 但绝不是立身之本。

此外,如果观点不同,不必强求。每个人有自己的判断,不 care 的东西瞥一眼忽略即可。不要因为网络评论的成本如此低廉就随意挥洒,毫无意义。

#6 楼 @liuchengxu 哥们,你样样洒洒一大短话,我没看出来啥意思。俺们是大佬粗,语文学的不好,看不太懂。我说的很明白,我将我自己的 Dotfiles 分离出来,这么长时间的打磨,自然是根据我自己需求才添加的功能。大家可以看到我仓库的历史,老早就开始搞的模块话,再说了,Layer 不一定就非得按照 spacemacs 那样,另外,我做模块话的时候,那时和之后 我前文提到的 2 个仓库,甚至第二个 fork 的都还不存在。更别说你的项目了。你的仓库 说实话,我没看出框架和 https://github.com/ctjhoa/spacevim 以及 https://github.com/Tehnix/spaceneovim 有什么区别。倒是你的 README.md 和 org 确实写的蛮好的。

另外 我之所以不再自己仓库搞,而是放到组织里面,就是因为我觉得,这样的项目,不该是一个人完成的。我也不可能了解那么多种语言开发的需求。如果有兴趣,完全可以加入组织一起维护。

@liuchengxu 另外,你仓库有这么一段, https://github.com/zvim/space-vim/blob/master/core/core_config.vim#L207-L257,我没看出来和 vim-plug 这个插件里面的有啥区别,兄弟,做项目,咱们 不能这样。附上 vim-plug 代码 https://github.com/junegunn/vim-plug/blob/master/plug.vim#L605-L655

#9 楼 @wsdjeg 天下文章一大抄,看你会抄不会抄。除了这个点,我还抄了很多,什么人都有,你可以再仔细看看,说不定还抄了你的呢。希望你能看得出来。

statusline 我也是 steal 了 vim-plug 的作者 junegunn,我还给他提了一个 issue, 你可以看这里 https://github.com/junegunn/vim-emoji/issues/23。后来 statusline 又抄了 https://github.com/sk1418/myConf/blob/master/common/.vimrc ,你可以看这里 https://www.v2ex.com/t/330610#reply24,我也告诉了他 KentY 这招是从他那里“偷学”来的。

这种事情不是学术剽窃,而是自由分享,其他人完全可以“拿来主义”。就像别人可以完全抽取 space-vim 的部分内容,作为自己的配置。只要你会抄,完全 OK.

我的时间不会浪费在这种琐碎的事情上。"做项目" ?恐怕你看的太重了,这仅仅是一个 vim 配置而已。等到有类似 spacemacs 那样的影响力再说也不迟。至于是否有必要放到组织里做件事,你可以去问一下 syl20bnr.

观点不同,看法不一,就此打住,不再回复。

弱弱的问一句,Emacs 我个人最喜欢的是‘主模式/副模式概念’像是一把武器不同场景加载不同配置。 vim 就没有,layout 不错直至感觉该不够,另外问下 layout 的加载机制是通过什么实现的?

#10 楼 @liuchengxu 你早该打住呢,如果不感兴趣,就不要样样洒洒的说一大断。自然会有兴趣的人。

#11 楼 @lilijreey 我的 vim 配置已经实现了这样的功能,支持全局用户配置,和就当前项目局部配置。

#1 楼 @huacnlee 我希望能有熟悉 vim ruby 开发的用户,提供一些建议,主要是补全,重构方面的配置

huacnlee [该话题已被删除] 提及了此话题。 01月10日 11:59

@huacnlee 请问目前社区是否有人在使用 vim 开发 ruby?

wsdjeg 回复

上次用 vim 写代码,写的贼慢,被老板喷,主要是我用的不熟,自动补全还是不行,没有遇到十分强大的自动补全插件

ForrestDouble 回复

老板一般都不让员工用 vim 的。

wsdjeg [该话题已被删除] 提及了此话题。 09月05日 22:00
wsdjeg 关闭了讨论。 09月05日 22:01
wsdjeg 重新开启了讨论。 09月05日 22:01
huacnlee 回复

你好,我只是将 https://github.com/SpaceVim/SpaceVim/blob/chinese_doc/docs/README_zh_cn.md 这篇文字内容同步到这里,但是目前出现一些问题,尤其是文章最开始图标不能像 github 那样排列才一排里面,目前我这部显示是每行只有一个小图片剧中显示。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号