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

Add ctrl-t key binding for flygrep (#3845)

close #3836
This commit is contained in:
Wang Shidong 2020-09-28 20:00:10 +08:00 committed by GitHub
parent a831c151b2
commit 36693a3bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 16 deletions

View File

@ -279,7 +279,17 @@ function! SpaceVim#layers#core#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['q', 'R'], '', 'restart-vim(TODO)', 1)
endif
call SpaceVim#mapping#space#def('nnoremap', ['q', 'r'], '', 'restart-vim-resume-layouts(TODO)', 1)
call SpaceVim#mapping#space#def('nnoremap', ['q', 't'], 'tabclose!', 'kill-current-tab', 1)
let lnum = expand('<slnum>') + s:lnum - 1
call SpaceVim#mapping#space#def('nnoremap', ['q', 't'], 'call call('
\ . string(s:_function('s:close_current_tab')) . ', [])',
\ ['close-current-tab',
\ [
\ '[SPC q t] is to close the current tab, if it is the last tab, do nothing.',
\ '',
\ 'Definition: ' . s:filename . ':' . lnum,
\ ]
\ ]
\ , 1)
call SpaceVim#mapping#gd#add('HelpDescribe', function('s:gotodef'))
let g:_spacevim_mappings_space.c = {'name' : '+Comments'}
@ -885,3 +895,9 @@ function! SpaceVim#layers#core#set_variable(var) abort
\ g:_spacevim_filetree_show_hidden_files)
endfunction
function! s:close_current_tab() abort
if tabpagenr('$') > 1
tabclose!
endif
endfunction

View File

@ -505,6 +505,30 @@ function! s:open_item() abort
endif
endfunction
function! s:open_item_in_tab() abort
let s:MPT._handle_fly = function('s:flygrep')
if getline('.') !=# ''
if s:grepid != 0
call s:JOB.stop(s:grepid)
endif
call s:MPT._clear_prompt()
let s:MPT._quit = 1
let line = getline('.')
let filename = fnameescape(split(line, ':\d\+:')[0])
let linenr = matchstr(line, ':\d\+:')[1:-2]
let colum = matchstr(line, '\(:\d\+\)\@<=:\d\+:')[1:-2]
if s:preview_able == 1
call s:close_preview_win()
endif
let s:preview_able = 0
noautocmd q
exe 'silent tabedit ' . filename
call s:update_history()
call cursor(linenr, colum)
noautocmd normal! :
endif
endfunction
function! s:open_item_vertically() abort
let s:MPT._handle_fly = function('s:flygrep')
if getline('.') !=# ''
@ -733,6 +757,7 @@ let s:MPT._function_key = {
\ "\<C-k>" : function('s:previous_item'),
\ "\<ScrollWheelUp>" : function('s:previous_item'),
\ "\<Return>" : function('s:open_item'),
\ "\<C-t>" : function('s:open_item_in_tab'),
\ "\<LeftMouse>" : function('s:move_cursor'),
\ "\<2-LeftMouse>" : function('s:double_click'),
\ "\<C-f>" : function('s:start_filter'),

View File

@ -85,7 +85,8 @@ The available scopes and corresponding keys are:
| Key Bindings | Descriptions |
| ----------------- | --------------------------------- |
| `<Esc>` | close FlyGrep buffer |
| `<Enter>` | open file at the cursor line |
| `<Enter>` | open item in current window |
| `Ctrl-t` | open item in new tab |
| `<Tab>` | move cursor line down |
| `Ctrl-j` | move cursor line down |
| `Shift-<Tab>` | move cursor line up |

View File

@ -96,17 +96,18 @@ SpaceVim 中的搜索命令以 `SPC s` 为前缀,前一个键是使用的工
在 FlyGrep 内的快捷键如下:
| 快捷键 | 功能描述 |
| ---------------- | ------------------ |
| `<Esc>` | 关闭 FlyGrep 窗口 |
| `<Enter>` | 打开光标下文件位置 |
| `<Tab>` | 移动至下一行 |
| `Ctrl-j` | 移动至下一行 |
| `<S-Tab>` | 移动至上一行 |
| `Ctrl-k` | 移动至上一行 |
| `<Backspace>` | 删除光标前一个字符 |
| `Ctrl-w` | 删除光标后的单词 |
| `Ctrl-u` | 删除光标前所有字符 |
| `Ctrl-k` | 删除光标后所有字符 |
| `Ctrl-a` / `<Home>` | 将光标定位到行首 |
| `Ctrl-e` / `<End>` | 将光标定位到行尾 |
| 快捷键 | 功能描述 |
| ------------------- | -------------------- |
| `<Esc>` | 关闭 FlyGrep 窗口 |
| `<Enter>` | 在当前窗口打开选中项 |
| `Ctrl-t` | 在新标签栏打开选中项 |
| `<Tab>` | 移动至下一行 |
| `Ctrl-j` | 移动至下一行 |
| `<S-Tab>` | 移动至上一行 |
| `Ctrl-k` | 移动至上一行 |
| `<Backspace>` | 删除光标前一个字符 |
| `Ctrl-w` | 删除光标后的单词 |
| `Ctrl-u` | 删除光标前所有字符 |
| `Ctrl-k` | 删除光标后所有字符 |
| `Ctrl-a` / `<Home>` | 将光标定位到行首 |
| `Ctrl-e` / `<End>` | 将光标定位到行尾 |

View File

@ -1570,6 +1570,7 @@ Flygrep 搜索窗口结果窗口内的常用快捷键:
| ------------------- | ---------------------- |
| `<Esc>` | 关闭搜索窗口 |
| `<Enter>` | 打开当前选中的文件位置 |
| `Ctrl-t` | 在新标签栏打开选中项 |
| `<Tab>` | 选中下一行文件位置 |
| `Shift-<Tab>` | 选中上一行文件位置 |
| `<Backspace>` | 删除上一个输入字符 |

View File

@ -1604,6 +1604,7 @@ Key bindings in FlyGrep buffer:
| ------------------- | --------------------------------- |
| `<Esc>` | close FlyGrep buffer |
| `<Enter>` | open file at the cursor line |
| `Ctrl-t` | open item in new tab |
| `<Tab>` | move cursor line down |
| `Shift-<Tab>` | move cursor line up |
| `<BackSpace>` | remove last character |