Vim C line comment function

The following function in ~/.vimrc is to comment out C line, and it works perfectly.

function CLC()
    execute "normal ^i/*\<ESC>$a*/\<ESC>"
endfunction

But I have two questions...
1. How do I make it comment out a range of lines.
2. How can I make it comment them out like this:

/*  
 * multiline   
 * comment   
 *   
 */

I am aware of the NERDCommenter plugin that would do both of these for me, but one of the mappings conflicts with the mapping for another plugin I have.


Solution 1:

:help NERDComMappings tells you how to change NERDCommenter's default mappings. For instance, put this into your ~/.vimrc to change the mapping prefix to <Leader>C:

nmap <Leader>Cc <Plug>NERDCommenterComment
xmap <Leader>Cc <Plug>NERDCommenterComment
nmap <Leader>C<Space> <Plug>NERDCommenterToggle
xmap <Leader>C<Space> <Plug>NERDCommenterToggle
nmap <Leader>Cm <Plug>NERDCommenterMinimal
xmap <Leader>Cm <Plug>NERDCommenterMinimal
nmap <Leader>Cs <Plug>NERDCommenterSexy
xmap <Leader>Cs <Plug>NERDCommenterSexy
nmap <Leader>Ci <Plug>NERDCommenterInvert
xmap <Leader>Ci <Plug>NERDCommenterInvert
nmap <Leader>Cy <Plug>NERDCommenterYank
xmap <Leader>Cy <Plug>NERDCommenterYank
nmap <Leader>Cl <Plug>NERDCommenterAlignLeft
xmap <Leader>Cl <Plug>NERDCommenterAlignLeft
nmap <Leader>Cb <Plug>NERDCommenterAlignBoth
xmap <Leader>Cb <Plug>NERDCommenterAlignBoth
nmap <Leader>Cn <Plug>NERDCommenterNest
xmap <Leader>Cn <Plug>NERDCommenterNest
nmap <Leader>Cu <Plug>NERDCommenterUncomment
xmap <Leader>Cu <Plug>NERDCommenterUncomment
nmap <Leader>C$ <Plug>NERDCommenterToEOL
xmap <Leader>C$ <Plug>NERDCommenterToEOL
nmap <Leader>CA <Plug>NERDCommenterAppend
xmap <Leader>CA <Plug>NERDCommenterAppend

nmap <Leader>ca <Plug>NERDCommenterAltDelims