Skip to content

Commit

Permalink
Add SPC j c key binding (#4443)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdjeg committed Aug 28, 2021
1 parent 4686974 commit b80606a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
15 changes: 14 additions & 1 deletion autoload/SpaceVim/layers/core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let s:SYS = SpaceVim#api#import('system')
let s:FILE = SpaceVim#api#import('file')
let s:MESSAGE = SpaceVim#api#import('vim#message')
let s:CMP = SpaceVim#api#import('vim#compatible')
let s:NOTI = SpaceVim#api#import('notify')


function! SpaceVim#layers#core#plugins() abort
Expand Down Expand Up @@ -149,7 +150,9 @@ function! SpaceVim#layers#core#config() abort
call SpaceVim#mapping#space#def('nmap', ['j', 'w'], '<Plug>(easymotion-overwin-w)', 'jump-to-a-word', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'q'], '<Plug>(easymotion-overwin-line)', 'jump-to-a-line', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'n'], "i\<cr>\<esc>", 'sp-newline', 0)
" call SpaceVim#mapping#space#def('nnoremap', ['j', 'o'], "i\<cr>\<esc>k$", 'open-line', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'c'], 'call call('
\ . string(s:_function('s:jump_last_change')) . ', [])',
\ 'jump-to-last-change', 1)
call SpaceVim#mapping#space#def('nnoremap', ['j', 's'], 'call call('
\ . string(s:_function('s:split_string')) . ', [0])',
\ 'split-sexp', 1)
Expand Down Expand Up @@ -461,6 +464,16 @@ let g:string_info = {
\ },
\ }

function! s:jump_last_change() abort
let [bufnum, lnum, col, off] = getpos("'.")
let [_, l, c, _] = getpos('.')
if lnum !=# l && c != col && lnum !=# 0 && col !=# 0
call setpos('.', [bufnum, lnum, col, off])
else
call s:NOTI.notify('no change position!', 'WarningMsg')
endif
endfunction

function! s:split_string(newline) abort
if s:is_string(line('.'), col('.'))
let save_cursor = getcurpos()
Expand Down
9 changes: 5 additions & 4 deletions docs/cn/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1732,16 +1732,17 @@ Denite/Unite 是一个强大的信息筛选浏览器,这类似于 Emacs 中的

| 快捷键 | 功能描述 |
| --------- | ------------------------------------------------ |
| `SPC j 0` | 跳至行首,并且在原始位置留下标签,以便跳回 |
| `SPC j $` | 跳至行尾,并且在原始位置留下标签,以便跳回 |
| `SPC j 0` | 跳至行首,并且在原始位置留下标签,以便跳回 |
| `SPC j b` | 向后回跳 |
| `SPC j f` | 向前跳 |
| `SPC j d` | 跳至当前目录某个文件夹 |
| `SPC j c` | 跳至前一个修改位置 |
| `SPC j D` | 跳至当前目录某个文件夹(在另外窗口展示文件列表) |
| `SPC j d` | 跳至当前目录某个文件夹 |
| `SPC j f` | 向前跳 |
| `SPC j i` | 跳至当前文件的某个函数,使用 Denite 打开语法树 |
| `SPC j I` | 跳至所有 Buffer 的语法树(TODO) |
| `SPC j j` | 跳至当前窗口的某个字符 (easymotion) |
| `SPC j J` | 跳至当前窗口的某两个字符的组合 (easymotion) |
| `SPC j j` | 跳至当前窗口的某个字符 (easymotion) |
| `SPC j k` | 跳至下一行,并且对齐下一行 |
| `SPC j l` | 跳至某一行 (easymotion) |
| `SPC j q` | show the dumb-jump quick look tooltip (TODO) |
Expand Down
7 changes: 4 additions & 3 deletions docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1730,14 +1730,15 @@ The `SPC j` prefix is for jumping, joining and splitting.

| Key Bindings | Descriptions |
| ------------ | --------------------------------------------------------------------------------- |
| `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 0` | go to the beginning 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 c` | jump to last change |
| `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 f` | jump forward |
| `SPC j I` | jump to a definition in any buffer (denite outline) |
| `SPC j i` | jump to a definition in 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 |
Expand Down

0 comments on commit b80606a

Please sign in to comment.