Guest User

Untitled

a guest
Apr 9th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.40 KB | None | 0 0
  1. vmap <F12> <ESC>`<:let fl=line(".")<CR>`>:let ll=line(".")<CR>:call ToggleComment(fl,ll)<CR>
  2.  
  3. function! ToggleComment(fl, ll)
  4.   let i=a:fl
  5.   let comment="//"
  6.   while i<=a:ll
  7.     let cl=getline(i)
  8.     if matchstr(cl, "^\s*//\s*.*")==""
  9.       let cl2=comment.cl
  10.           else
  11.       let cl2=substitute(cl, "//", "", "")
  12.     endif
  13.     call setline(i, cl2)
  14.     let i=i+1
  15.   endwhile
  16. endfunction
Add Comment
Please, Sign In to add comment