I'm trying to remove the verilog block comment start:
I'm trying to do this inside a function:
call setline(line('.'), substitute(getline('.'), '/*','',''))
Of some reason, it doesn't to anything. I tried to use \V, I tried escaping. It seems that no matter what I do, it never removes the comment.
The comment end syntax is removed with no problems:
call setline(line('.'), substitute(getline('.'), "*/", '', ''))
Update: The function I'm trying to build is:
func! s:comment_line(set,vmode) let lnum = line('.') let line = getline('.') call setline(line('.'), substitute(getline('.'), '/\*', '', '')) call setline(lnum, substitute(line, "*/", '', '')) norm! j endfunc
I'm using this mapping:
nnoremap <silent> + : call <SID>comment_line(0,0)<Cr> vnoremap <silent> + : call <SID>comment_line(0,1)<Cr>
When I pick a few lines with visual/visual line/visual block, I get a
*/ deleted but never a
(I removed other parts of the function for clarity)
The reason I avoided using
s:/\*:: is the errors.
The answer below suggests adding the
Also, the suggestion to use
(which executes the substitution on all the selected range), is redundant here because the function is called for each line separately (A function is called for every line in a selected visual/visual line). So in this case one must use either
if line('.')==a:firstline exe a:firstline.",".a:lastline."s:\*/::e" endif " do only once
s:/\*::. This also works in a function
\Vdoesn't work? don't add extra escape if you are using
execute()you just put the line
s:/\*::there all by itself. Check the answer I provided.