mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 12:50:05 +08:00
Add SPC c ; for comment operator
This commit is contained in:
parent
3516b9fd90
commit
5dd469b37f
@ -20,6 +20,8 @@ function! SpaceVim#mapping#g#init() abort
|
|||||||
nnoremap g, g,
|
nnoremap g, g,
|
||||||
let g:_spacevim_mappings_g[';'] = ['call feedkeys("g;", "n")', 'older position in change list']
|
let g:_spacevim_mappings_g[';'] = ['call feedkeys("g;", "n")', 'older position in change list']
|
||||||
nnoremap g; g;
|
nnoremap g; g;
|
||||||
|
let g:_spacevim_mappings_g['@'] = ['call feedkeys("g@", "n")', 'call operatorfunc']
|
||||||
|
nnoremap g@ g@
|
||||||
|
|
||||||
let g:_spacevim_mappings_g['#'] = ['call feedkeys("\<Plug>(incsearch-nohl-g#)")', 'search under cursor backward']
|
let g:_spacevim_mappings_g['#'] = ['call feedkeys("\<Plug>(incsearch-nohl-g#)")', 'search under cursor backward']
|
||||||
let g:_spacevim_mappings_g['*'] = ['call feedkeys("\<Plug>(incsearch-nohl-g*)")', 'search under cursor forward']
|
let g:_spacevim_mappings_g['*'] = ['call feedkeys("\<Plug>(incsearch-nohl-g*)")', 'search under cursor forward']
|
||||||
|
@ -78,6 +78,11 @@ function! SpaceVim#mapping#space#init() abort
|
|||||||
call SpaceVim#mapping#space#def('nmap', ['c', 'L'], '<Plug>NERDCommenterInvert', 'toggle comment lines', 0, 1)
|
call SpaceVim#mapping#space#def('nmap', ['c', 'L'], '<Plug>NERDCommenterInvert', 'toggle comment lines', 0, 1)
|
||||||
call SpaceVim#mapping#space#def('nmap', ['c', 'p'], 'vip<Plug>NERDCommenterComment', 'comment paragraphs', 0, 1)
|
call SpaceVim#mapping#space#def('nmap', ['c', 'p'], 'vip<Plug>NERDCommenterComment', 'comment paragraphs', 0, 1)
|
||||||
call SpaceVim#mapping#space#def('nmap', ['c', 'P'], 'vip<Plug>NERDCommenterInvert', 'toggle comment paragraphs', 0, 1)
|
call SpaceVim#mapping#space#def('nmap', ['c', 'P'], 'vip<Plug>NERDCommenterInvert', 'toggle comment paragraphs', 0, 1)
|
||||||
|
|
||||||
|
nnoremap <silent> <Plug>CommentOperator :set opfunc=<SID>commentOperator<Cr>g@
|
||||||
|
let g:_spacevim_mappings_space.c[';'] = ['call feedkeys("\<Plug>CommentOperator")', 'comment operator']
|
||||||
|
nmap <silent> [SPC]c; <Plug>CommentOperator
|
||||||
|
|
||||||
" in nerdcomment if has map to <plug>... the default mapping will be
|
" in nerdcomment if has map to <plug>... the default mapping will be
|
||||||
" disable, so we add it for compatibility
|
" disable, so we add it for compatibility
|
||||||
nmap <Leader>cc <Plug>NERDCommenterComment
|
nmap <Leader>cc <Plug>NERDCommenterComment
|
||||||
@ -304,4 +309,25 @@ function! SpaceVim#mapping#space#langSPC(m, keys, cmd, desc, is_cmd) abort
|
|||||||
call extend(g:_spacevim_mappings_prefixs['[SPC]'], get(g:, '_spacevim_mappings_space', {}))
|
call extend(g:_spacevim_mappings_prefixs['[SPC]'], get(g:, '_spacevim_mappings_space', {}))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:commentOperator(type, ...)
|
||||||
|
let sel_save = &selection
|
||||||
|
let &selection = "inclusive"
|
||||||
|
let reg_save = @@
|
||||||
|
|
||||||
|
if a:0 " Invoked from Visual mode, use gv command.
|
||||||
|
silent exe "normal! gv"
|
||||||
|
call feedkeys("\<Plug>NERDCommenterComment")
|
||||||
|
elseif a:type == 'line'
|
||||||
|
call feedkeys('`[V`]')
|
||||||
|
call feedkeys("\<Plug>NERDCommenterComment")
|
||||||
|
else
|
||||||
|
call feedkeys('`[v`]')
|
||||||
|
call feedkeys("\<Plug>NERDCommenterComment")
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &selection = sel_save
|
||||||
|
let @@ = reg_save
|
||||||
|
set opfunc=
|
||||||
|
endfunction
|
||||||
|
|
||||||
" vim:set et sw=2 cc=80:
|
" vim:set et sw=2 cc=80:
|
||||||
|
Loading…
Reference in New Issue
Block a user