diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 2423605a4..af323b11d 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -79,6 +79,11 @@ function! SpaceVim#mapping#space#init() abort call SpaceVim#mapping#space#def('nmap', ['c', 'p'], 'vipNERDCommenterComment', 'comment paragraphs', 0, 1) call SpaceVim#mapping#space#def('nmap', ['c', 'P'], 'vipNERDCommenterInvert', 'toggle comment paragraphs', 0, 1) + nnoremap CommentToLine :comment_to_line(0) + nnoremap CommentToLineInvert :comment_to_line(1) + call SpaceVim#mapping#space#def('nmap', ['c', 't'], 'CommentToLine', 'comment to line', 0, 1) + call SpaceVim#mapping#space#def('nmap', ['c', 'T'], 'CommentToLineInvert', 'toggle comment to line', 0, 1) + nnoremap CommentOperator :set opfunc=commentOperatorg@ let g:_spacevim_mappings_space[';'] = ['call feedkeys("\CommentOperator")', 'comment operator'] nmap [SPC]; CommentOperator @@ -330,4 +335,20 @@ function! s:commentOperator(type, ...) set opfunc= endfunction +function! s:comment_to_line(invert) abort + let line = str2nr(input('line number :')) + let ex = line - line('.') + if ex > 0 + exe 'normal! V'. ex .'j' + elseif ex == 0 + else + exe 'normal! V'. ex .'k' + endif + if a:invert + call feedkeys("\NERDCommenterInvert") + else + call feedkeys("\NERDCommenterComment") + endif +endfunction + " vim:set et sw=2 cc=80: