mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:10:06 +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
|
||||
|
||||
default `[Window]` key is `s`, and it is setup by `g:spacevim_windows_leader`.
|
||||
|
||||
Key | Mode | Action
|
||||
----- |:----:| ------------------
|
||||
`q` | Normal | Smart buffer close
|
||||
`s`+`p` | Normal | Split nicely
|
||||
`s`+`v` | Normal | :split
|
||||
`s`+`g` | Normal | :vsplit
|
||||
`s`+`t` | Normal | Open new tab (:tabnew)
|
||||
`s`+`o` | Normal | Close other windows (:only)
|
||||
`s`+`x` | Normal | Remove buffer, leave blank window
|
||||
`s`+`q` | Normal | Closes current buffer (:close)
|
||||
`s`+`Q` | Normal | Removes current buffer (:bdelete)
|
||||
`Tab` | Normal | Next window or tab
|
||||
`Shift`+`Tab` | Normal | Previous window or tab
|
||||
`q` | Normal | Smart close current window
|
||||
`[Window]`+`p` | Normal | Split nicely
|
||||
`[Window]`+`v` | Normal | :split
|
||||
`[Window]`+`g` | Normal | :vsplit
|
||||
`[Window]`+`t` | Normal | Open new tab (:tabnew)
|
||||
`[Window]`+`o` | Normal | Close other windows (:only)
|
||||
`[Window]`+`x` | Normal | Remove buffer, leave blank window
|
||||
`[Window]`+`q` | Normal | Closes current buffer (:close)
|
||||
`[Widnow]`+`Q` | Normal | Removes current buffer (:bdelete)
|
||||
`[Window]`+`c` | Normal | Clear up all of other buffers and windows
|
||||
`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>`+`sg` | Normal | Vertical split with previous buffer
|
||||
|
||||
|
@ -75,3 +75,24 @@ function! SpaceVim#mapping#clearBuffers() abort
|
||||
endif
|
||||
endfor
|
||||
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.'")
|
||||
|
||||
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>',
|
||||
\'Open previous buffer in split window' , 'split|wincmd p|e#')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sg', ':vsplit<CR>:wincmd p<CR>:e#<CR>',
|
||||
\'Open previous buffer in vsplit window' , 'vsplit|wincmd p|e#')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sv', ':call SpaceVim#mapping#split_previous_buffer()<CR>',
|
||||
\'Open previous buffer in split window' , 'call SpaceVim#mapping#split_previous_buffer()')
|
||||
call SpaceVim#mapping#def('nnoremap <silent>', '<Leader>sg', ':call SpaceVim#mapping#vertical_split_previous_buffer()<CR>',
|
||||
\'Open previous buffer in vsplit window' , 'call SpaceVim#mapping#vertical_split_previous_buffer()')
|
||||
endfunction
|
||||
function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
||||
if !empty(a:key)
|
||||
|
@ -5,3 +5,9 @@ function! SpaceVim#util#globpath(path, expr) abort
|
||||
return split(globpath(a:path, a:expr), '\n')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#util#echoWarn(msg) abort
|
||||
echohl WarningMsg
|
||||
echo a:msg
|
||||
echohl None
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user