From cc952345861fec1d7df1458b5bf2dd5b5259c100 Mon Sep 17 00:00:00 2001 From: GBProd Date: Sat, 19 Dec 2020 14:00:47 +0100 Subject: [PATCH] Add: introduce splitjoin (#3956) --- autoload/SpaceVim/layers/edit.vim | 6 ++++++ config/plugins/splitjoin.vim | 3 +++ docs/documentation.md | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 config/plugins/splitjoin.vim diff --git a/autoload/SpaceVim/layers/edit.vim b/autoload/SpaceVim/layers/edit.vim index ef346417a..9879d6437 100644 --- a/autoload/SpaceVim/layers/edit.vim +++ b/autoload/SpaceVim/layers/edit.vim @@ -32,6 +32,7 @@ function! SpaceVim#layers#edit#plugins() abort \ [g:_spacevim_root_dir . 'bundle/vim-jplus', { 'on_map' : '(jplus' }], \ [g:_spacevim_root_dir . 'bundle/tabular', { 'merged' : 0}], \ [g:_spacevim_root_dir . 'bundle/vim-better-whitespace', { 'on_cmd' : ['StripWhitespace', 'ToggleWhitespace', 'DisableWhitespace', 'EnableWhitespace']}], + \ ['andrewradev/splitjoin.vim',{ 'merged' : 0, 'loadconf' : 1}], \ ] if executable('fcitx') call add(plugins,[g:_spacevim_root_dir . 'bundle/fcitx.vim', { 'on_event' : 'InsertEnter'}]) @@ -217,6 +218,11 @@ function! SpaceVim#layers#edit#config() abort \ . string(s:_function('s:transpose_with_next')) . ', ["line"])', \ 'swap-current-line-with-next-one', 1) + " splitjoin + call SpaceVim#mapping#space#def('nnoremap', ['j', 'o'], + \ 'SplitjoinJoin', 'join into a single-line statement', 1) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'm'], + \ 'SplitjoinSplit', 'split a one-liner into multiple lines', 1) endfunction function! s:transpose_with_previous(type) abort diff --git a/config/plugins/splitjoin.vim b/config/plugins/splitjoin.vim new file mode 100644 index 000000000..dc5b197ad --- /dev/null +++ b/config/plugins/splitjoin.vim @@ -0,0 +1,3 @@ +" Disable splitjoin default mappings +let g:splitjoin_split_mapping = '' +let g:splitjoin_join_mapping = '' diff --git a/docs/documentation.md b/docs/documentation.md index 768a1ecbd..3c442d27f 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -1773,6 +1773,8 @@ The `SPC j` prefix is for jumping, joining and splitting. | Key Bindings | Descriptions | | ------------ | ----------------------------------------------------------------------------- | | `J` | join the current line with the next line | +| `SPC j o` | join a code block into a single-line statement | +| `SPC j m` | split a one-liner into multiple lines | | `SPC j k` | go to next line and indent it using auto-indent rules | | `SPC j n` | split the current line at point, insert a new line and auto-indent | | `SPC j o` | split the current line at point but let point on current line |