In Vim, when I comment a multi-line visual selection using NERDCommenter, the blank lines in the selection are not commented. In the example below, I select all 5 lines and type “\cl” (for NERDCommenterAlignLeft), but the 3rd line, which is blank, is not commented.
Before:
" Normalize Markdown : Remove Trailing # From Headers
nnoremap <Leader>qq :%s/ \+#\+ *$//gc<CR>
" Normalize Markdown : Remove Trailing Whitespace
nnoremap <Leader>qw :%s/\s\+$//gc<CR>
After:
" " Normalize Markdown : Remove Trailing # From Headers
" nnoremap <Leader>qq :%s/ \+#\+ *$//gc<CR>
" " Normalize Markdown : Remove Trailing Whitespace
" nnoremap <Leader>qw :%s/\s\+$//gc<CR>
This is how it has been implemented in NERDCommenter plugin. If you open the plugin file (NERD_commenter.vim) and look for a function named
s:CanCommentLine, you will see that it has the following check:So, before the plugin goes ahead to comment a line, it checks if it is an empty line. If so, the plugin does not comment it and skips to the next line.
A quickfix would be to simply remove this part of the code from your plugin file.