AndrewRadev/splitjoin.vim

Can't work in visual after changing keymap

fjchen7 opened this issue · 2 comments

When I do not add additional configuration, the default gJ and gS work in visual mode well. However After I changing keymap like the following

let g:splitjoin_split_mapping = 'cS'
let g:splitjoin_join_mapping  = 'cJ'

cS and cJ only work in normal mode, and only can work on one line.

environment: neovim 0.8

When I do not add additional configuration, the default gJ and gS work in visual mode well.

There's no particular action that splitjoin takes in visual mode, unless I've forgotten something big. When I test the default mappings locally, gJ just does the default visual mode mapping :help gJ. I don't think gS in visual mode does anything. Could you describe what is happening for you? What does "work well" mean for your setup? Maybe you could share a screencast video or something?

The plugin should only work in normal mode. Here's the relevant mappings:

nnoremap <silent> <plug>SplitjoinSplit :<c-u>call sj#Split()<cr>
nnoremap <silent> <plug>SplitjoinJoin :<c-u>call sj#Join()<cr>
if g:splitjoin_join_mapping != ''
exe 'nnoremap <silent> '.g:splitjoin_join_mapping.' :<c-u>call <SID>Mapping(g:splitjoin_join_mapping, "sj#Join")<cr>'
endif
if g:splitjoin_split_mapping != ''
exe 'nnoremap <silent> '.g:splitjoin_split_mapping.' :<c-u>call <SID>Mapping(g:splitjoin_split_mapping, "sj#Split")<cr>'
endif

jimzk commented

Sorry for my bad expression. It works well mean: when I visualize multiple lines and press gJ, it can join all visualized lines. However when I change the key from gJ to cJ then nothing happen when I do the same thing when pressing cJ

But I may understand it wrong. I find that the gJ in visual mode is the builtin command but not taken by splitjoin. gJ and gS from splitjoin only work in normal mode.

Closed. Thanks for your kind reply.