From 8a4d2774feecf09d55bcdee4806f7131ed123a22 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Sat, 1 Jul 2017 19:54:30 +0800
Subject: [PATCH 01/10] Add comment doc

---
 docs/documentation.md | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/docs/documentation.md b/docs/documentation.md
index e6079bf4e..f7d2d0f6c 100644
--- a/docs/documentation.md
+++ b/docs/documentation.md
@@ -78,6 +78,7 @@ title:  "Documentation"
         * [Persistent highlighting](#persistent-highlighting)
     * [Editing](#editing)
         * [Text insertion commands](#text-insertion-commands)
+        * [Commenting](#commenting)
         * [Multi-Encodings](#multi-encodings)
     * [Errors handling](#errors-handling)
 * [Achievements](#achievements)
@@ -1113,6 +1114,7 @@ SpaceVim uses `g:spacevim_search_highlight_persist` to keep the searched express
 Text insertion commands (start with `i`):
 
 Key binding | Description
+----------- | -----------
 `SPC i l l` | insert lorem-ipsum list
 `SPC i l p` | insert lorem-ipsum paragraph
 `SPC i l s` | insert lorem-ipsum sentence
@@ -1126,6 +1128,25 @@ Key binding | Description
 `SPC i U 4` | insert UUIDv4 (use universal argument to insert with CID format)
 `SPC i U U` | insert UUIDv4 (use universal argument to insert with CID format)
 
+#### Commenting
+
+Comments are handled by [nerdcommenter](https://github.com/scrooloose/nerdcommenter), it’s bound to the following keys.
+
+Key Binding | Description
+----------- | -----------
+`SPC ;` | comment operator
+`SPC c h` | hide/show comments
+`SPC c l` | comment lines
+`SPC c L` | invert comment lines
+`SPC c p` | comment paragraphs
+`SPC c P` | invert comment paragraphs
+`SPC c t` | comment to line
+`SPC c T` | invert comment to line
+`SPC c y` | comment and yank
+`SPC c Y` | invert comment and yank
+
+**Tips:** To comment efficiently a block of line use the combo `SPC ; SPC j l`
+
 #### Multi-Encodings
 
 SpaceVim use utf-8 as default encoding. there are four options for these case:

From be329308b0b5e37db027631c98e561c08a0f5643 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Tue, 11 Jul 2017 04:21:57 +0800
Subject: [PATCH 02/10] Add SPC c l for toggle comment lines

---
 autoload/SpaceVim/mapping/space.vim | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 29971d82c..16e61bc9d 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -74,7 +74,7 @@ function! SpaceVim#mapping#space#init() abort
   "
   " Toggles the comment state of the selected line(s). If the topmost selected
   " line is commented, all selected lines are uncommented and vice versa.
-  call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call NERDComment("n", "Toggle")', 'Toggle comment line(s)', 1)
+  call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call feedkeys("\<Plug>NERDCommenterComment")', 'Toggle comment line(s)', 1, 1)
 
   let g:_spacevim_mappings_space.e = {'name' : '+Errors/Encoding'}
   let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'}
@@ -205,10 +205,11 @@ function! SpaceVim#mapping#space#init() abort
         \ 'clear search highlight', 1)
 endfunction
 
-function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
+function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
   if s:has_map_to_spc()
     return
   endif
+  let is_visual = a:0 > 0 ? a:1 : 0
   if a:is_cmd
     let cmd = ':<C-u>' . a:cmd . '<CR>' 
     let lcmd = a:cmd
@@ -222,6 +223,11 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
     endif
   endif
   exe a:m . ' <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
+  if is_visual
+    if a:m ==# 'nnoremap'
+      exe 'xnoremap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
+    endif
+  endif
   if len(a:keys) == 2
     let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc]
   elseif len(a:keys) == 3

From 12dd80c664da37eecb1161bad0911af814c5f2d3 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Tue, 11 Jul 2017 05:00:45 +0800
Subject: [PATCH 03/10] Add SPC c L for invert comment lines

---
 autoload/SpaceVim/mapping/space.vim | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 16e61bc9d..26e44d008 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -75,6 +75,13 @@ function! SpaceVim#mapping#space#init() abort
   " Toggles the comment state of the selected line(s). If the topmost selected
   " line is commented, all selected lines are uncommented and vice versa.
   call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call feedkeys("\<Plug>NERDCommenterComment")', 'Toggle comment line(s)', 1, 1)
+  call SpaceVim#mapping#space#def('nnoremap', ['c', 'L'], 'call feedkeys("\<Plug>NERDCommenterInvert")', 'Toggle comment line(s)', 1, 1)
+  " in nerdcomment if has map to <plug>... the default mapping will be
+  " disable, so we add it for compatibility
+  nnoremap <Leader>cc :call feedkeys("\<Plug>NERDCommenterComment")<Cr>
+  xnoremap <Leader>cc :call feedkeys("\<Plug>NERDCommenterComment")<Cr>
+  nnoremap <Leader>ci :call feedkeys("\<Plug>NERDCommenterInvert")<Cr>
+  xnoremap <Leader>ci :call feedkeys("\<Plug>NERDCommenterInvert")<Cr>
 
   let g:_spacevim_mappings_space.e = {'name' : '+Errors/Encoding'}
   let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'}

From ed10d8609fbb24afc5c48be46675a07c4e18e955 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Tue, 11 Jul 2017 05:12:37 +0800
Subject: [PATCH 04/10] Add SPC c p/P for comment paragraphs

---
 autoload/SpaceVim/mapping/space.vim | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 26e44d008..1ce69c934 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -76,6 +76,8 @@ function! SpaceVim#mapping#space#init() abort
   " line is commented, all selected lines are uncommented and vice versa.
   call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call feedkeys("\<Plug>NERDCommenterComment")', 'Toggle comment line(s)', 1, 1)
   call SpaceVim#mapping#space#def('nnoremap', ['c', 'L'], 'call feedkeys("\<Plug>NERDCommenterInvert")', 'Toggle comment line(s)', 1, 1)
+  call SpaceVim#mapping#space#def('nnoremap', ['c', 'p'], 'call feedkeys("vip\<Plug>NERDCommenterComment")', 'Toggle comment line(s)', 1)
+  call SpaceVim#mapping#space#def('nnoremap', ['c', 'P'], 'call feedkeys("vip\<Plug>NERDCommenterInvert")', 'Toggle comment line(s)', 1)
   " in nerdcomment if has map to <plug>... the default mapping will be
   " disable, so we add it for compatibility
   nnoremap <Leader>cc :call feedkeys("\<Plug>NERDCommenterComment")<Cr>

From 1193760c924421b119be2895846cf0e3410474fd Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Wed, 12 Jul 2017 08:08:31 +0800
Subject: [PATCH 05/10] Fix comment mappings

---
 autoload/SpaceVim/mapping/space.vim | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 1ce69c934..1e07bad75 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -74,16 +74,16 @@ function! SpaceVim#mapping#space#init() abort
   "
   " Toggles the comment state of the selected line(s). If the topmost selected
   " line is commented, all selected lines are uncommented and vice versa.
-  call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call feedkeys("\<Plug>NERDCommenterComment")', 'Toggle comment line(s)', 1, 1)
-  call SpaceVim#mapping#space#def('nnoremap', ['c', 'L'], 'call feedkeys("\<Plug>NERDCommenterInvert")', 'Toggle comment line(s)', 1, 1)
-  call SpaceVim#mapping#space#def('nnoremap', ['c', 'p'], 'call feedkeys("vip\<Plug>NERDCommenterComment")', 'Toggle comment line(s)', 1)
-  call SpaceVim#mapping#space#def('nnoremap', ['c', 'P'], 'call feedkeys("vip\<Plug>NERDCommenterInvert")', 'Toggle comment line(s)', 1)
+  call SpaceVim#mapping#space#def('nmap', ['c', 'l'], '<Plug>NERDCommenterComment', '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>NERDCommenterInvert', 'toggle comment paragraphs', 0, 1)
   " in nerdcomment if has map to <plug>... the default mapping will be
   " disable, so we add it for compatibility
-  nnoremap <Leader>cc :call feedkeys("\<Plug>NERDCommenterComment")<Cr>
-  xnoremap <Leader>cc :call feedkeys("\<Plug>NERDCommenterComment")<Cr>
-  nnoremap <Leader>ci :call feedkeys("\<Plug>NERDCommenterInvert")<Cr>
-  xnoremap <Leader>ci :call feedkeys("\<Plug>NERDCommenterInvert")<Cr>
+  nmap <Leader>cc <Plug>NERDCommenterComment
+  xmap <Leader>cc <Plug>NERDCommenterComment
+  nmap <Leader>ci <Plug>NERDCommenterInvert
+  xmap <Leader>ci <Plug>NERDCommenterInvert
 
   let g:_spacevim_mappings_space.e = {'name' : '+Errors/Encoding'}
   let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'}
@@ -235,6 +235,8 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
   if is_visual
     if a:m ==# 'nnoremap'
       exe 'xnoremap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
+    elseif a:m ==# 'nmap'
+      exe 'xmap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
     endif
   endif
   if len(a:keys) == 2

From 3516b9fd90e82fba55577f75393b261ed1843bf2 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Thu, 13 Jul 2017 04:37:54 +0800
Subject: [PATCH 06/10] Fix comment paragraphs

---
 autoload/SpaceVim/mapping/space.vim | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 1e07bad75..475bc7055 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -76,8 +76,8 @@ function! SpaceVim#mapping#space#init() abort
   " line is commented, all selected lines are uncommented and vice versa.
   call SpaceVim#mapping#space#def('nmap', ['c', 'l'], '<Plug>NERDCommenterComment', '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>NERDCommenterInvert', 'toggle 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)
   " in nerdcomment if has map to <plug>... the default mapping will be
   " disable, so we add it for compatibility
   nmap <Leader>cc <Plug>NERDCommenterComment

From 5dd469b37fd6de0e49a3746542de735df943db37 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Thu, 13 Jul 2017 06:18:41 +0800
Subject: [PATCH 07/10] Add SPC c ; for comment operator

---
 autoload/SpaceVim/mapping/g.vim     |  2 ++
 autoload/SpaceVim/mapping/space.vim | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/autoload/SpaceVim/mapping/g.vim b/autoload/SpaceVim/mapping/g.vim
index 941267b89..09659f9c0 100644
--- a/autoload/SpaceVim/mapping/g.vim
+++ b/autoload/SpaceVim/mapping/g.vim
@@ -20,6 +20,8 @@ function! SpaceVim#mapping#g#init() abort
     nnoremap g, g,
     let g:_spacevim_mappings_g[';'] = ['call feedkeys("g;", "n")', 'older position in change list']
     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 forward']
diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 475bc7055..9ff8441f7 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -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', 'p'], 'vip<Plug>NERDCommenterComment', '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
   " disable, so we add it for compatibility
   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', {}))
 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:

From e40eec9cc4f274cbc45ae48d66a4f68e8bddcd6d Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Thu, 13 Jul 2017 06:34:13 +0800
Subject: [PATCH 08/10] Use SPC ; instead of SPC c ;

---
 autoload/SpaceVim/mapping/space.vim | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index 9ff8441f7..2423605a4 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -80,8 +80,8 @@ function! SpaceVim#mapping#space#init() abort
   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
+  let g:_spacevim_mappings_space[';'] = ['call feedkeys("\<Plug>CommentOperator")', 'comment operator']
+  nmap <silent> [SPC]; <Plug>CommentOperator
 
   " in nerdcomment if has map to <plug>... the default mapping will be
   " disable, so we add it for compatibility

From 0f56158bc7ec42c0cd5182ede51656a072b46333 Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Thu, 13 Jul 2017 08:15:37 +0800
Subject: [PATCH 09/10] Comment to line

---
 autoload/SpaceVim/mapping/space.vim | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

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'], 'vip<Plug>NERDCommenterComment', 'comment paragraphs', 0, 1)
   call SpaceVim#mapping#space#def('nmap', ['c', 'P'], 'vip<Plug>NERDCommenterInvert', 'toggle comment paragraphs', 0, 1)
 
+  nnoremap <silent> <Plug>CommentToLine :<SID>comment_to_line(0)<Cr>
+  nnoremap <silent> <Plug>CommentToLineInvert :<SID>comment_to_line(1)<Cr>
+  call SpaceVim#mapping#space#def('nmap', ['c', 't'], '<Plug>CommentToLine', 'comment to line', 0, 1)
+  call SpaceVim#mapping#space#def('nmap', ['c', 'T'], '<Plug>CommentToLineInvert', 'toggle comment to line', 0, 1)
+
   nnoremap <silent> <Plug>CommentOperator :set opfunc=<SID>commentOperator<Cr>g@
   let g:_spacevim_mappings_space[';'] = ['call feedkeys("\<Plug>CommentOperator")', 'comment operator']
   nmap <silent> [SPC]; <Plug>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("\<Plug>NERDCommenterInvert")
+  else
+    call feedkeys("\<Plug>NERDCommenterComment")
+  endif
+endfunction
+
 " vim:set et sw=2 cc=80:

From edd3439e65d0890f2f3208e4973880496f76948a Mon Sep 17 00:00:00 2001
From: wsdjeg <wsdjeg@163.com>
Date: Fri, 14 Jul 2017 04:14:58 +0800
Subject: [PATCH 10/10] Fix SPC c t

---
 autoload/SpaceVim/mapping/space.vim | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim
index af323b11d..febb9b889 100644
--- a/autoload/SpaceVim/mapping/space.vim
+++ b/autoload/SpaceVim/mapping/space.vim
@@ -79,8 +79,8 @@ function! SpaceVim#mapping#space#init() abort
   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)
 
-  nnoremap <silent> <Plug>CommentToLine :<SID>comment_to_line(0)<Cr>
-  nnoremap <silent> <Plug>CommentToLineInvert :<SID>comment_to_line(1)<Cr>
+  nnoremap <silent> <Plug>CommentToLine :call <SID>comment_to_line(0)<Cr>
+  nnoremap <silent> <Plug>CommentToLineInvert :call <SID>comment_to_line(1)<Cr>
   call SpaceVim#mapping#space#def('nmap', ['c', 't'], '<Plug>CommentToLine', 'comment to line', 0, 1)
   call SpaceVim#mapping#space#def('nmap', ['c', 'T'], '<Plug>CommentToLineInvert', 'toggle comment to line', 0, 1)
 
@@ -336,13 +336,17 @@ function! s:commentOperator(type, ...)
 endfunction
 
 function! s:comment_to_line(invert) abort
-  let line = str2nr(input('line number :'))
+  let input = input('line number :')
+  if empty(input)
+    return
+  endif
+  let line = str2nr(input)
   let ex = line - line('.')
   if ex > 0
     exe 'normal! V'. ex .'j'
   elseif ex == 0
   else
-    exe 'normal! V'. ex .'k'
+    exe 'normal! V'. abs(ex) .'k'
   endif
   if a:invert
     call feedkeys("\<Plug>NERDCommenterInvert")