From 9e347d96a862ca7fa1b18e8cb74ea939d5ad014b Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Mon, 10 Aug 2020 20:39:37 +0800 Subject: [PATCH] Add SPC b s key binding (#3696) --- autoload/SpaceVim/mapping/space.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index fd503905c..12c8ed48e 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -6,6 +6,8 @@ " License: GPLv3 "============================================================================= +let s:BUF = SpaceVim#api#import('vim#buffer') + let s:file = expand(':~') let s:funcbeginline = expand('') + 1 function! SpaceVim#mapping#space#init() abort @@ -308,6 +310,10 @@ function! SpaceVim#mapping#space#init() abort \ ] \ ] \ , 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 's'], + \ 'call call(' + \ . string(function('s:switch_scratch_buffer')) + \ . ', [])', 'switch-to-scratch-buffer', 1) let s:lnum = expand('') + 3 call SpaceVim#mapping#space#def('nnoremap', ['b', 'p'], 'bp', ['previous-buffer', \ [ @@ -659,6 +665,14 @@ function! s:create_new_named_tab() abort endif endfunction +let s:scratch_buffer = -1 +function! s:switch_scratch_buffer() abort + if !bufexists(s:scratch_buffer) || !empty(getbufvar(s:scratch_buffer, '&filetype', '')) + let s:scratch_buffer = s:BUF.create_buf(1, 1) + endif + exe 'buffer' s:scratch_buffer +endfunction + function! s:windows_transient_state() abort let state = SpaceVim#api#import('transient_state')