mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-22 17:05:42 +08:00
Catch errors when open previous buffer
This commit is contained in:
parent
1cff5459b0
commit
764c17b453
25
README.md
25
README.md
@ -437,19 +437,22 @@ Key | Mode | Action
|
|||||||
|
|
||||||
##### Window Management
|
##### Window Management
|
||||||
|
|
||||||
|
default `[Window]` key is `s`, and it is setup by `g:spacevim_windows_leader`.
|
||||||
|
|
||||||
Key | Mode | Action
|
Key | Mode | Action
|
||||||
----- |:----:| ------------------
|
----- |:----:| ------------------
|
||||||
`q` | Normal | Smart buffer close
|
`q` | Normal | Smart close current window
|
||||||
`s`+`p` | Normal | Split nicely
|
`[Window]`+`p` | Normal | Split nicely
|
||||||
`s`+`v` | Normal | :split
|
`[Window]`+`v` | Normal | :split
|
||||||
`s`+`g` | Normal | :vsplit
|
`[Window]`+`g` | Normal | :vsplit
|
||||||
`s`+`t` | Normal | Open new tab (:tabnew)
|
`[Window]`+`t` | Normal | Open new tab (:tabnew)
|
||||||
`s`+`o` | Normal | Close other windows (:only)
|
`[Window]`+`o` | Normal | Close other windows (:only)
|
||||||
`s`+`x` | Normal | Remove buffer, leave blank window
|
`[Window]`+`x` | Normal | Remove buffer, leave blank window
|
||||||
`s`+`q` | Normal | Closes current buffer (:close)
|
`[Window]`+`q` | Normal | Closes current buffer (:close)
|
||||||
`s`+`Q` | Normal | Removes current buffer (:bdelete)
|
`[Widnow]`+`Q` | Normal | Removes current buffer (:bdelete)
|
||||||
`Tab` | Normal | Next window or tab
|
`[Window]`+`c` | Normal | Clear up all of other buffers and windows
|
||||||
`Shift`+`Tab` | Normal | Previous window or tab
|
`Tab` | Normal | Next window or tab (:wincmd w)
|
||||||
|
`Shift`+`Tab` | Normal | Previous window or tab (:wincmd p)
|
||||||
`<leader>`+`sv` | Normal | Split with previous buffer
|
`<leader>`+`sv` | Normal | Split with previous buffer
|
||||||
`<leader>`+`sg` | Normal | Vertical split with previous buffer
|
`<leader>`+`sg` | Normal | Vertical split with previous buffer
|
||||||
|
|
||||||
|
@ -75,3 +75,24 @@ function! SpaceVim#mapping#clearBuffers() abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#mapping#split_previous_buffer() abort
|
||||||
|
if bufnr('#') == -1
|
||||||
|
call SpaceVim#util#echoWarn('There is no previous buffer')
|
||||||
|
else
|
||||||
|
split
|
||||||
|
wincmd w
|
||||||
|
e#
|
||||||
|
endif
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#mapping#vertical_split_previous_buffer() abort
|
||||||
|
if bufnr('#') == -1
|
||||||
|
call SpaceVim#util#echoWarn('There is no previous buffer')
|
||||||
|
else
|
||||||
|
vsplit
|
||||||
|
wincmd w
|
||||||
|
e#
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
@ -66,10 +66,10 @@ function! SpaceVim#mapping#leader#defindglobalMappings() abort
|
|||||||
\ "echo 'Use <leader>S to sourced line.'")
|
\ "echo 'Use <leader>S to sourced line.'")
|
||||||
|
|
||||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>qr', 'q', 'Toggle recording','')
|
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>qr', 'q', 'Toggle recording','')
|
||||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sv', ':split<CR>:wincmd p<CR>:e#<CR>',
|
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sv', ':call SpaceVim#mapping#split_previous_buffer()<CR>',
|
||||||
\'Open previous buffer in split window' , 'split|wincmd p|e#')
|
\'Open previous buffer in split window' , 'call SpaceVim#mapping#split_previous_buffer()')
|
||||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sg', ':vsplit<CR>:wincmd p<CR>:e#<CR>',
|
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sg', ':call SpaceVim#mapping#vertical_split_previous_buffer()<CR>',
|
||||||
\'Open previous buffer in vsplit window' , 'vsplit|wincmd p|e#')
|
\'Open previous buffer in vsplit window' , 'call SpaceVim#mapping#vertical_split_previous_buffer()')
|
||||||
endfunction
|
endfunction
|
||||||
function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
||||||
if !empty(a:key)
|
if !empty(a:key)
|
||||||
|
@ -5,3 +5,9 @@ function! SpaceVim#util#globpath(path, expr) abort
|
|||||||
return split(globpath(a:path, a:expr), '\n')
|
return split(globpath(a:path, a:expr), '\n')
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#util#echoWarn(msg) abort
|
||||||
|
echohl WarningMsg
|
||||||
|
echo a:msg
|
||||||
|
echohl None
|
||||||
|
endfunction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user