I'm using a modified version of https://stackoverflow.com/a/1676672/618584
autocmd FileType php,styl,javascript let b:comment_leader = '// '
noremap <C-\> :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
"noremap <C-\> :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
I want to remove comments using the same command (see commented out line above). What I need to do is check if the line begins with '//' and if so, map the to removing the comment.
Any idea how to do this?
I was previously using tpope's commentary plugin, and to achieve what I wnt with that, I'd do:
" comments toggle
autocmd FileType php setlocal commentstring=\/\/\ %s
nmap <C-\> gcc
xmap <C-\> gcugin I'd do:
But again, I do not want to use a plugin because I only code in JS and PHP.