Does anyone know a visual studio keyboard short cut to swap around two sides of a statement?

前端 未结 6 1426
借酒劲吻你
借酒劲吻你 2021-01-04 02:39

Just wondering if anyone knows the keyboard shortcut to swap around two sides of a statement. For example:

I want to swap



        
6条回答
  •  没有蜡笔的小新
    2021-01-04 02:58

    Since I was not happy with the answers where I need to enter complicated strings into the Visual Studio search/replace dialog, I wrote myself a little AutoHotkey script, that performs the swaps with only the need to press a keyboard shortcut. And this, no matter if you are in VS or in another IDE.
    This hotkey (start it once simply from a textfile as script or compiled to exe) runs whenever Win+Ctrl-S is pressed

    #^s Up::  
     clipboard := "" ; Empty the clipboard
     Sendinput {Ctrl down}c{ctrl up}
     Clipwait
     Loop, Parse, clipboard, `n, `r  ; iterates over seperates lines
     {   
      array := StrSplit(RegExReplace(A_LoopField,";",""),"=")  ; remove semicolon and split by '='
      SendInput, % Trim(array[2]) . " = " .  Trim(array[1]) . ";{Enter}"
     }
    return 
    

    Many more details are possible, e.g. also supporting code where lines end with a comma

    ...and I can put many more hotkeys and hotstrings into the same script, e.g. for my most mistyped words:

    ::esle::else    ; this 1 line rewrites all my 'else' typos
    

提交回复
热议问题