1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-15 19:45:46 +08:00

Change default keybinding loading (#3792)

* Make default keyBinding load after custom#load

* Remove key binding ctrl-c in normal mode

* Remove key binding Ctrl-x
This commit is contained in:
Wang Shidong 2020-09-10 01:52:40 +08:00 committed by GitHub
parent 8626aba4e9
commit b71ee0c96f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 32 deletions

View File

@ -1226,7 +1226,6 @@ function! SpaceVim#end() abort
endif endif
if !g:spacevim_vimcompatible if !g:spacevim_vimcompatible
nnoremap <silent><C-x> <C-w>x
cnoremap <C-f> <Right> cnoremap <C-f> <Right>
" Navigation in command line " Navigation in command line
cnoremap <C-a> <Home> cnoremap <C-a> <Home>
@ -1386,7 +1385,6 @@ function! SpaceVim#begin() abort
endif endif
call SpaceVim#default#options() call SpaceVim#default#options()
call SpaceVim#default#layers() call SpaceVim#default#layers()
call SpaceVim#default#keyBindings()
call SpaceVim#commands#load() call SpaceVim#commands#load()
endfunction endfunction

View File

@ -290,8 +290,6 @@ function! SpaceVim#default#keyBindings() abort
call SpaceVim#mapping#def('nnoremap <silent>','g=',':call SpaceVim#mapping#format()<cr>','format current buffer','call SpaceVim#mapping#format()') call SpaceVim#mapping#def('nnoremap <silent>','g=',':call SpaceVim#mapping#format()<cr>','format current buffer','call SpaceVim#mapping#format()')
call SpaceVim#mapping#def('nnoremap <silent>', '<C-c>', ':<c-u>call SpaceVim#util#CopyToClipboard()<cr>',
\ 'Copy buffer absolute path to X11 clipboard','call SpaceVim#util#CopyToClipboard()')
endfunction endfunction
fu! s:tobur(num) abort fu! s:tobur(num) abort

View File

@ -129,6 +129,16 @@ function! SpaceVim#mapping#space#init() abort
\ ] \ ]
\ , 1) \ , 1)
let s:lnum = expand('<slnum>') + s:funcbeginline let s:lnum = expand('<slnum>') + s:funcbeginline
call SpaceVim#mapping#space#def('nnoremap', ['w', 'x'], 'wincmd x',
\ ['window-switch-placement',
\ [
\ '[SPC w x] is to jump to exchange current window with next one.',
\ '',
\ 'Definition: ' . s:file . ':' . s:lnum,
\ ]
\ ]
\ , 1)
let s:lnum = expand('<slnum>') + s:funcbeginline
call SpaceVim#mapping#space#def('nnoremap', ['w', 'k'], 'wincmd k', call SpaceVim#mapping#space#def('nnoremap', ['w', 'k'], 'wincmd k',
\ ['window-up', \ ['window-up',
\ [ \ [

View File

@ -67,5 +67,7 @@ call SpaceVim#begin()
call SpaceVim#custom#load() call SpaceVim#custom#load()
call SpaceVim#default#keyBindings()
call SpaceVim#end() call SpaceVim#end()
" vim:set et sw=2 cc=80: " vim:set et sw=2 cc=80:

View File

@ -152,7 +152,10 @@ Neovim 运行在 iTerm2 上,采用 SpaceVim配色为_base16-solarized-da
**临时快捷键菜单** **临时快捷键菜单**
SpaceVim 根据需要定义了很多临时快捷键,这可以避免需要重复某些操作时过多按下 `SPC` 前缀键。当临时快捷键启用时,会在窗口下方打开一个快捷键介绍窗口,提示每一临时快捷键的功能。此外一些额外的辅助信息也将会显示出来。 SpaceVim 根据需要定义了很多临时快捷键,
这可以避免需要重复某些操作时过多按下 `SPC` 前缀键。
当临时快捷键启用时,会在窗口下方打开一个快捷键介绍窗口,
提示每一临时快捷键的功能。此外一些额外的辅助信息也将会显示出来。
文本移动临时快捷键: 文本移动临时快捷键:
@ -259,7 +262,6 @@ SpaceVim 根据需要定义了很多临时快捷键,这可以避免需要重
或者 `~/.cache/vimfiles/.cache/vimrc/` 或者 `~/.cache/vimfiles/.cache/vimrc/`
这依据当前使用的是 Neovim 还是 Vim。 这依据当前使用的是 Neovim 还是 Vim。
除了 `on_cmd` 以外,还有一些其它的选项,可以通过 除了 `on_cmd` 以外,还有一些其它的选项,可以通过
`:h dein-options` 查阅。 `:h dein-options` 查阅。
@ -777,8 +779,6 @@ SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性
| `Ctrl-b` | 向上翻页 (`C-b` / `C-u`) | | `Ctrl-b` | 向上翻页 (`C-b` / `C-u`) |
| `Ctrl-e` | 向下滚屏 (`3 Ctrl-e/j`) | | `Ctrl-e` | 向下滚屏 (`3 Ctrl-e/j`) |
| `Ctrl-y` | 向上滚屏 (`3Ctrl-y/k`) | | `Ctrl-y` | 向上滚屏 (`3Ctrl-y/k`) |
| `Ctrl-c` | 复制当前文件绝对路径 |
| `Ctrl-x` | 切换窗口文件 |
| `Ctrl-Shift-Up` | 向上移动当前行 | | `Ctrl-Shift-Up` | 向上移动当前行 |
| `Ctrl-Shift-Down` | 向下移动当前行 | | `Ctrl-Shift-Down` | 向下移动当前行 |
@ -824,7 +824,10 @@ SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性
### 快捷键导航 ### 快捷键导航
当 Normal 模式下按下前缀键后出现输入延迟,则会在屏幕下方打开一个快捷键导航窗口,提示当前可用的快捷键及其功能描述,目前支持的前缀键有:`[SPC]``[Window]``<Leader>``g``z` 当 Normal 模式下按下前缀键后出现输入延迟,
则会在屏幕下方打开一个快捷键导航窗口,
提示当前可用的快捷键及其功能描述,
目前支持的前缀键有:`[SPC]``[Window]``<Leader>``g``z`
这些前缀的按键为: 这些前缀的按键为:
@ -834,6 +837,21 @@ SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性
| `[Window]` | `windows_leader` / `s` | SpaceVim 默认窗口前缀键 | | `[Window]` | `windows_leader` / `s` | SpaceVim 默认窗口前缀键 |
| `<leader>` | 默认的 Vim leader 键 | Vim/Neovim 默认前缀键 | | `<leader>` | 默认的 Vim leader 键 | Vim/Neovim 默认前缀键 |
默认的 `<Leader>` 键是 `\`, 如果需要修改 `<Leader>`
键则需要使用启动函数修改 `g:mapleader` 的值,
比如使用逗号 `,` 作为 `<Leader>` 按键。
```vim
function! myspacevim#before() abort
let g:mapleader = ','
endfunction
```
**注意:** 在函数中修改 `g:mapleader` 的值,不可以省略前缀 `g:`
因为函数中的变量默认作用域是 `l:`,这与 Vim 的帮助 `:h mapleader`
有些许不一样。
默认情况下,快捷键导航将在输入延迟超过 1000ms 后打开,你可以通过修改 Vim 的 `'timeoutlen'` 选项来修改成适合自己的延迟时间长度。 默认情况下,快捷键导航将在输入延迟超过 1000ms 后打开,你可以通过修改 Vim 的 `'timeoutlen'` 选项来修改成适合自己的延迟时间长度。
例如Normal 模式下按下空格键,你将会看到: 例如Normal 模式下按下空格键,你将会看到:
@ -1100,6 +1118,7 @@ SpaceVim 选项 `window_leader` 的值来设为其它按键:
| `SPC w V` | 垂直分离窗口,并切换至新窗口 | | `SPC w V` | 垂直分离窗口,并切换至新窗口 |
| `SPC w w` | 切换至前一窗口 | | `SPC w w` | 切换至前一窗口 |
| `SPC w W` | 选择一个窗口 | | `SPC w W` | 选择一个窗口 |
| `SPC w x` | 切换窗口文件 |
### 缓冲区管理 ### 缓冲区管理
@ -1689,7 +1708,6 @@ Denite/Unite 是一个强大的信息筛选浏览器,这类似于 Emacs 中的
### 工程管理 ### 工程管理
当打开一个文件时SpaceVim 会自动切换当前目录至包含该文件的项目根目录, 当打开一个文件时SpaceVim 会自动切换当前目录至包含该文件的项目根目录,
项目根目录的检测依据 `project_rooter_patterns` 这一选项,其默认值为: 项目根目录的检测依据 `project_rooter_patterns` 这一选项,其默认值为:

View File

@ -813,7 +813,7 @@ If only one file buffer is opened, a file is opened in the active window, otherw
The following key bindings are the general key bindings for moving cursor. The following key bindings are the general key bindings for moving cursor.
| Key Bindings | Descriptions | | Key Bindings | Descriptions |
| ---------------- | ------------------------------------------------- | | ---------------- | ---------------------------------------- |
| `h` | move cursor left | | `h` | move cursor left |
| `j` | move cursor down | | `j` | move cursor down |
| `k` | move cursor up | | `k` | move cursor up |
@ -829,7 +829,6 @@ The following key bindings are the general key bindings for moving cursor.
| `Ctrl-b` | Smart page backward (`C-b` / `C-u`) | | `Ctrl-b` | Smart page backward (`C-b` / `C-u`) |
| `Ctrl-e` | Smart scroll down (`3 Ctrl-e/j`) | | `Ctrl-e` | Smart scroll down (`3 Ctrl-e/j`) |
| `Ctrl-y` | Smart scroll up (`3Ctrl-y/k`) | | `Ctrl-y` | Smart scroll up (`3Ctrl-y/k`) |
| `Ctrl-c` | Copy full path of current buffer to X11 clipboard |
### Native functions ### Native functions
@ -851,7 +850,6 @@ The following key bindings are the general key bindings for moving cursor.
| `<Tab>` | Indent to right and re-select | | `<Tab>` | Indent to right and re-select |
| `Shift-<Tab>` | Indent to left and re-select | | `Shift-<Tab>` | Indent to left and re-select |
| `Ctrl-q` | `Ctrl-w` | | `Ctrl-q` | `Ctrl-w` |
| `Ctrl-x` | Switch buffer and placement |
| `Ctrl-Shift-Up` | move lines up | | `Ctrl-Shift-Up` | move lines up |
| `Ctrl-Shift-Down` | move lines down | | `Ctrl-Shift-Down` | move lines down |
@ -885,6 +883,20 @@ The default keys of these prefixs are:
| `[WIN]` | `windows_leader` / `s` | window mapping prefix of SpaceVim | | `[WIN]` | `windows_leader` / `s` | window mapping prefix of SpaceVim |
| `<Leader>` | default vim leader | default leader prefix of vim/Neovim | | `<Leader>` | default vim leader | default leader prefix of vim/Neovim |
The default value of `<Leader>` is `\`, if you want to change this key,
you need to use bootstrap function. For example, use `,` as the `<Leader>` key:
```vim
function! myspacevim#before() abort
let g:mapleader = ','
endfunction
```
**NOTE:** When changing valuable `g:mapleader` in a function.
you can not omit the valuable scope. Because the default scope
of a valuable in function is `l:`. It seems different from what you
seee in vim help `:h mapleader`.
By default the guide buffer will be displayed 1000ms after the keys being pressed. By default the guide buffer will be displayed 1000ms after the keys being pressed.
You can change the delay by adding vim option `'timeoutlen'` to your bootstrap function. You can change the delay by adding vim option `'timeoutlen'` to your bootstrap function.
@ -1160,6 +1172,7 @@ Windows manipulation commands (start with `w`):
| `SPC w V` | vertical split and focus new window | | `SPC w V` | vertical split and focus new window |
| `SPC w w` | cycle and focus between windows | | `SPC w w` | cycle and focus between windows |
| `SPC w W` | select window using vim-choosewin | | `SPC w W` | select window using vim-choosewin |
| `SPC w x` | exchange current window with next one |
### Buffers and Files ### Buffers and Files