1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 15:19:12 +08:00

Fix vimcompatible mode (#2174)

This commit is contained in:
Wang Shidong 2018-09-17 21:09:15 +08:00 committed by GitHub
parent 1887a5bb5c
commit 4a5c313639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 19 deletions

View File

@ -766,6 +766,14 @@ function! SpaceVim#end() abort
let g:spacevim_windows_leader = ''
let g:spacevim_windows_smartclose = 0
endif
if !g:spacevim_vimcompatible
nnoremap <silent><C-x> <C-w>x
cnoremap <C-f> <Right>
" Navigation in command line
cnoremap <C-a> <Home>
cnoremap <C-b> <Left>
endif
call SpaceVim#server#connect()
if g:spacevim_enable_neocomplcache

View File

@ -258,14 +258,7 @@ function! SpaceVim#default#keyBindings() abort
" Navigate window
nnoremap <silent><C-q> <C-w>
if !g:spacevim_vimcompatible
nnoremap <silent><C-x> <C-w>x
endif
" Navigation in command line
cnoremap <C-a> <Home>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
" Fast saving

View File

@ -17,7 +17,9 @@ function! SpaceVim#layers#core#plugins() abort
call add(plugins, ['Shougo/vimproc.vim', {'build' : [(executable('gmake') ? 'gmake' : 'make')]}])
endif
call add(plugins, ['rhysd/clever-f.vim', {'merged' : 0}])
if !g:spacevim_vimcompatible
call add(plugins, ['rhysd/clever-f.vim', {'merged' : 0}])
endif
call add(plugins, ['scrooloose/nerdcommenter', { 'loadconf' : 1, 'merged' : 0}])
call add(plugins, ['andymass/vim-matchup', {'merged' : 0}])

View File

@ -35,7 +35,7 @@ function! SpaceVim#mapping#space#init() abort
vnoremap <silent><nowait> [SPC] :<c-u>LeaderGuideVisual " "<CR>
nmap <Space> [SPC]
vmap <Space> [SPC]
if g:spacevim_enable_language_specific_leader
if !g:spacevim_vimcompatible && g:spacevim_enable_language_specific_leader
nmap , [SPC]l
xmap , [SPC]l
endif

View File

@ -254,20 +254,29 @@ endf
### Vim 兼容模式
以下为 SpaceVim 中与 Vim 默认情况下的一些差异,而在兼容模式下,
以下所有差异将不存在,可以通过设置 `vimcompatible = true` 来启用 Vim 兼容模式。
以下为 SpaceVim 中与 Vim 默认情况下的一些差异。
- Noraml 模式下 `s` 按键不再删除光标下的字符,在 SpaceVim 中,
它是 `Windows` 快捷键的前缀(可以在配置文件中设置成其他按键)。
如果希望回复 `s` 按键原先的功能,可以通过 `windows_leader = ""` 使用一个空字符串来禁用这一功能。
它是窗口相关快捷键的前缀(可以在配置文件中设置成其他按键)。
如果希望恢复 `s` 按键原先的功能,可以通过 `windows_leader = ""` 将窗口前缀键设为空字符串来禁用这一功能。
- Normal 模式下 `,` 按键在 Vim 默认情况下是重复上一次的 `f``F``t``T` 按键,但在 SpaceVim 中默认被用作为语言专用的前缀键。如果需要禁用此选项,
可设置 `enable_language_specific_leader = false`
- Normal 模式下 `q` 按键在 SpaceVim 中被设置为了智能关闭窗口,
即大多数情况下按下 `q` 键即可关闭当前窗口。可以通过 `windows_smartclose = ""` 使用一个空字符串来禁用这一功能,或修改为其他按键。
- 命令行模式下 `Ctrl-a` 按键在 SpaceVim 中被修改为了移动光标至命令行行首。
- 命令行模式下 `Ctrl-b` 按键被映射为方向键 `<Left>`, 用以向左移动光标。
- 命令行模式下 `Ctrl-f` 按键被映射为方向键 `<Right>`, 用以向右移动光标。
- 命令行模式下 `<C-a>` 按键在 SpaceVim 中被修改为了移动光标至命令行行首。
可以通过设置 `vimcompatible = true` 来启用 Vim 兼容模式,而在兼容模式下,
以上所有差异将不存在。当然,也可通过对应的选项禁用某一个差异。比如,恢复逗号`,`的原始功能,
可以通过禁用语言专用的前缀键:
```toml
[options]
enable_language_specific_leader = false
```
如果发现有其他区别,可以[提交 PR](http://spacevim.org/development/)。
### 私有模块

View File

@ -17,7 +17,7 @@ description: "General documentation about how to using SpaceVim, including the q
- [Get SpaceVim log](#get-spacevim-log)
- [Custom Configuration](#custom-configuration)
- [Bootstrap Functions](#bootstrap-functions)
- [Vim Compatible Mode](#vim-compatible-mode)
- [Vim compatible mode](#vim-compatible-mode)
- [Private Layers](#private-layers)
- [Debug upstream plugins](#debug-upstream-plugins)
- [Concepts](#concepts)
@ -254,9 +254,9 @@ func! myspacevim#before() abort
endf
```
### Vim Compatible Mode
### Vim compatible mode
This a list of different key bindings between SpaceVim and origin vim. If you still want to use this origin function, you can enable vimcompatible mode, via `vimcompatible = true` in `[options]` section.
This a list of different key bindings between SpaceVim and origin vim.
- The `s` key does replace cursor char, but in SpaceVim it is the `Window` key bindings specific leader key by default (which can be set on another key binding in dotfile). If you still prefer the origin function of `s`, you can use an empty string to disable this feature.
@ -271,6 +271,19 @@ the option is `g:spacevim_enable_language_specific_leader`, default value is 1.
the option is `g:spacevim_windows_smartclose`, default value is `q`. If you still prefer the origin function of `q`, you can use an empty string to disable this feature.
- The `Ctrl-a` binding on the command line auto-completes variable names, but in SpaceVim it moves to the cursor to the beginning of the command.
- `Ctrl-b` in command line mode is mapped to `<Left>`, which will move cursor to the left.
- `Ctrl-f` in command line mode is mapped to `<Right>`, which will move cursor to the right.
SpaceVim provides a vimcompatible mode, in vimcompatible mode, all the different points above will disappear,
you can enable vimcompatible mode via `vimcompatible = true` in `[options]` section.
If you want to disable one of these differences, use the relevant options.
For example, to disable language specific leader, you may add following to your configuration file:
```toml
[options]
enable_language_specific_leader = false
```
[Send a PR](http://spacevim.org/development/) to add the differences you found in this section.

View File

@ -51,6 +51,7 @@ The next release is v0.9.0.
- Improve statusline for nerdtree buffer ([#2117](https://github.com/SpaceVim/SpaceVim/pull/2117))
- Improve statusline for mundo buffer ([#2118](https://github.com/SpaceVim/SpaceVim/pull/2118))
- Improve compatibility with old vim ([#2130](https://github.com/SpaceVim/SpaceVim/pull/2130))
- Improve vimcompatible mode ([#2174](https://github.com/SpaceVim/SpaceVim/pull/2174))
### Changed