congdantoancau

Toggle block comment code

Oct 17th, 2018
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; TOGGLE BLOCK COMMENT CODE
  2. ; Ref: https://stackoverflow.com/questions/20009502/autohotkey-code-block-comment-and-uncomment-hotkeys
  3. ^+/::
  4.     clipsaved := Clipboard
  5.     Clipboard :=
  6.     Send ^c
  7.     Sleep 40
  8.     text := Clipboard
  9.     if (text != "")
  10.     {
  11.         if Instr(text, "/*")
  12.         {
  13.             ; Remove block comment signatures /**/
  14.             text := StrReplace(text, "/*")
  15.             text := StrReplace(text, "*/")
  16.             Clipboard := text
  17.         }
  18.         else
  19.         {
  20.             ; Add block comment signatures /**/
  21.             if InStr(text, "`r`n")
  22.                 Clipboard := "/*`r`n" + text + "`r`n"
  23.             else
  24.                 Clipboard := "/*" + text "*/"
  25.         }
  26.         Clipboard := Clipboard ; For somewhere Clipboard conflict
  27.         Send ^v
  28.     }
  29.     Clipboard := clipsaved
  30. return
Add Comment
Please, Sign In to add comment